开发者

Getting Flexmock assertions to trigger failing Rspec test using Ruby on Rails

Using RSpec(2.5.0) and flexmock, and i'm finding that even if i tell a flexmocked object that it should never receive a method, my test passes anyway.

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
class Foo
end

describe Foo do 

  describe "flexmock" do

      it 'shoul开发者_如何转开发d 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

While this is a contrived example i'm looking to do things with flexmock like ensure emails get sent

flexmock(Email).should_receive(:friend_request).once

inside of other methods but this doesn't really help me if the flexmock-ed object doesn't ever tell rspec that it's criteria weren't met.

Any way i can get Flexmock to trigger a failing rspec test when it's expectations aren't met?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜