使用RSpec(2.5.0)和flexmock,我发现即使我告诉flexmocked对象它永远不会接收方法,我的测试仍然会通过。
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
class Foo
end
describe Foo do
describe "flexmock" do
it 'should fail when a method is called too many times' do
f = flexmock(:foo => :bar)
f.should_receive(:foo).never
f.foo
## this test should fail, but doesn't
end
end
end
→ rspec spec/models/foo_spec.rb
.
Finished in 0.00361 seconds
1 example, 0 failures
虽然这是一个人为的例子,但我希望用flexmock做一些事情,比如确保发送电子邮件
flexmock(电子邮件).should_receive(:friend_request)。一旦
在其他方法中,但如果flexmock-ed对象没有告诉rspec它的标准没有得到满足,这对我没有帮助。
任何方式我可以让Flexmock在未达到预期时触发失败的rspec测试吗?