Reputation: 620
Would appreciate if someone could tell me why this won't pass, it's getting nil instead of value
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
Upvotes: 0
Views: 55
Reputation: 45941
Because puts
always returns nil
, #hi
always returns nil
.
Change it to:
class Hello
def hi
"hello"
end
end
Upvotes: 3
Reputation: 96
I haven't tested it, but you should also be able to test against $stdout. It should receive the
Upvotes: 0
Reputation: 19496
puts
just outputs the string, but returns nil
as the value, so hi
is just returning that nil value.
Upvotes: 2