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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.