Rspec: should_receive on an instance class

270 views Asked by At

Here is what I am trying to do:

before(:each) do
    @user = Factory.build(:user)
    @user.stub!(:must_not_be_in_somewhere).and_return(true)
 end

it "should send a email if we are 2 weeks from last email" do
    User.any_instance.should_receive(:deliver_promo_code).exactly(111).times

    post :create, :user => @user.attributes, :format => :json
 end

The code works but the test is not failing when it should... Anyone has an idea of what is wrong with that code?

0

There are 0 answers