Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ruby和rspec-测试失败_Ruby_Testing_Rspec - Fatal编程技术网

ruby和rspec-测试失败

ruby和rspec-测试失败,ruby,testing,rspec,Ruby,Testing,Rspec,我应该通过这次考试 describe 'new' do it "takes a parameter and returns a HangpersonGame object" do @hangpersonGame = HangpersonGame.new('glorp') expect(@hangpersonGame).to be_an_instance_of(HangpersonGame) expect(@hangpersonGame.wo

我应该通过这次考试

describe 'new' do
    it "takes a parameter and returns a HangpersonGame object" do      
      @hangpersonGame = HangpersonGame.new('glorp')
      expect(@hangpersonGame).to be_an_instance_of(HangpersonGame)
      expect(@hangpersonGame.word).to eq('glorp')
      expect(@hangpersonGame.guesses).to eq('')
      expect(@hangpersonGame.wrong_guesses).to eq('')
    end
  end
我的代码是

class HangpersonGame


    attr_accessor :word
    attr_accessor :guesses
    attr_accessor :wrong_guesses

  def initialize(word)
    @word = word
    @guesses = nil
    @wrong_guesses = nil

  end
end

测试失败了。为什么?我已经分别运行了代码,它似乎起了作用。

测试预期猜测和错误猜测为空字符串,而不是NilThank,这是有效的。测试预期猜测和错误猜测为空字符串,而不是NilThank,这是有效的。