我应该让这个测试通过。
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
测试失败。为什么?我已经单独运行代码,它似乎工作。