Reputation: 248
i do test in ruby but get false message , but expected is true.
i try give message '1' and in test give '1' but have error.
What i do wrong ?
test code
assert_equal('Klient nr 1: Jan Kowalski, stan konta: 0 PLN', c1.to_s)
my code
def to_s()
puts "Klient nr #{@p.nr}: #{@p.name} #{@p.surname}, stan konta: #{self.balance} PLN"
end
and have screen
Upvotes: 1
Views: 66
Reputation: 7522
Your to_s method is printing the string, but it's not actually returning the string. Instead, it's returning nil, which is definitely not equal to your expected string.
Change it to return the string and you should be good:
def to_s()
return "Klient nr #{@p.nr}: #{@p.name} #{@p.surname}, stan konta: #{self.balance} PLN"
end
Upvotes: 1