Rspec:在实例类上的should_receive

时间:2012-05-31 00:10:06

标签: ruby-on-rails ruby rspec rspec-rails rr

以下是我要做的事情:

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

代码可以工作,但测试不应该失败... 任何人都知道该代码有什么问题吗?

0 个答案:

没有答案