Why doesn't the test work?
require 'rspec' class Test attr_accessor :name def girl puts "Hello #{name}" end end describe "Hello" do it "Hello Mari" do name1=Test.new name1.name="Mari" name1.girl=="Hello Mari" end end Why doesn't the test work?
require 'rspec' class Test attr_accessor :name def girl puts "Hello #{name}" end end describe "Hello" do it "Hello Mari" do name1=Test.new name1.name="Mari" name1.girl=="Hello Mari" end end Beginners may be advised to refer to the http://rspec.info documentation more often.
It doesn't work because tests write a little differently.
name1 = Test.new name1.name = 'Mari' expect(name1.girl).to eq('Hello Mari') puts . To return a string, you can simply write "Hello #{name}" (without puts). And if you want to test the standard output, this link stackoverflow.com/questions/17709317/how-to-test-puts-in-rspec/… can help. - NikSource: https://ru.stackoverflow.com/questions/880218/
All Articles