以下是我要做的事情:
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
代码可以工作,但测试不应该失败... 任何人都知道该代码有什么问题吗?