Ruby on rails 使用RubyonRails获取Flexmock断言以触发失败的Rspec测试
使用RSpec(2.5.0)和flexmock,我发现即使我告诉flexmock对象它永远不会收到方法,我的测试还是通过了Ruby on rails 使用RubyonRails获取Flexmock断言以触发失败的Rspec测试,ruby-on-rails,testing,rspec,rspec2,Ruby On Rails,Testing,Rspec,Rspec2,使用RSpec(2.5.0)和flexmock,我发现即使我告诉flexmock对象它永远不会收到方法,我的测试还是通过了 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
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(电子邮件)。应收到(:朋友请求)。一次
在其他方法中,但是如果flexmock对象没有告诉rspec它的标准没有得到满足,那么这并不能真正帮助我
有没有办法让Flexmock在未达到预期时触发失败的rspec测试