如果有人能告诉我为什么这不会通过,那将会感激,它会变为零而不是价值
class Hello
def hi
puts "hello"
end
end
describe Hello do
before do
@obj = Hello.new
end
describe "#hi" do
it "should say hello" do
@obj.hi.should == "hello"
end
end
end
答案 0 :(得分:3)
由于puts
始终返回nil
,#hi
始终会返回nil
。
将其更改为:
class Hello
def hi
"hello"
end
end
答案 1 :(得分:2)
puts
只输出字符串,但返回nil
作为值,因此hi
只返回该nil值。
答案 2 :(得分:0)
我还没有测试过,但你也应该可以测试$ stdout。它应该收到