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
我的文件.rb:
module M
class C
puts "class TEXT" # label1
def meth
puts "method TEXT" # label2
return "something"
end
end
end
输出是:
class TEXT
M::C
should print everything
Finished in 0.75 seconds
1 example, 0 failures
最后是一个问题:“为什么label2
在测试运行后没有打印 -- ("method TEXT")?”
PS Ruby192,rspec2