[rspec-users] Stub conflict?

James jamescway at gmail.com
Fri Apr 6 00:03:06 UTC 2012


Hi,
I have two stubs in two different specs (one model, one controller).
For some reason they are causing some strange conflict with one
another.
If I comment out the controller stub, the model spec passes.

Controller Spec
-----------------------------------
require 'spec_helper'
describe MyClass::SomeController do
    it 'should do stuff' do
      Some::Base.stub!(:mystub)   #IF I COMMENT THIS OUT IT PASSES
    end
end


I have this line in another model spec
------------------------------------------------------
    Some::Thing.should_receive(:mystub).exactly(4).times.and_return
nil


'Thing' is a child class of 'Base'.

Here is the error:
----------------------------
     Failure/Error:
Some::Thing.should_receive(:mystub).exactly(4).times.and_return nil
       (<Some::Thing (class)>).mystub(any args)
           expected: 4 times
           received: 2 times



  * rspec (2.9.0)
  * rspec-core (2.9.0)
  * rspec-expectations (2.9.0)
  * rspec-mocks (2.9.0)
  * rspec-rails (2.9.0)
rails (3.0.4)
ruby 1.8.7

Thanks in advance!

James







More information about the rspec-users mailing list