my_file_spec.rb:
require 'spec_helper'
require 'my_file'
module M
describe C do
it 'should print everything' do
c = C.new
c.meth.should == "something"
end
end
end
my_file.rb:
module M
class C
puts "class TEXT" # label1
def meth
puts "method TEXT" # label2
return "something"
end
end
end
The output is:
class TEXT
M::C
should print everything
Finished in 0.75 seconds
1 example, 0 failures
And finally the question: "Why wasn't the label2
-- ("method TEXT") printed after the test had been run?"
P.S. Ruby192, rspec2
Try using $stderr.puts "method TEXT"
. This works for me. Just be aware that it is considered bad practice to write tests that have output that you need to examine manually, but I guess you already know that...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With