【发布时间】:2014-06-03 05:22:47
【问题描述】:
我正在使用 rspec 版本 2.14.8 和 Ruby 2.1.1。
我在 test_spec.rb 中有以下内容
describe 'My code' do
it 'should work' do
expect ( nil ).to be_nil
expect ( "test" ).to eq( "test")
end
end
当我运行这个简单的规范 (rspec test_spec.rb) 时,我收到以下错误:
Failures:
1) My code should work
Failure/Error: expect ( nil ).to be_nil
NoMethodError:
undefined method `to' for nil:NilClass
# ./test_spec.rb:3:in `block (2 levels) in <top (required)>'
怎么了!?
【问题讨论】: