这是我正在尝试做的事情:
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
代码有效,但测试并没有失败……任何人都知道该代码有什么问题吗?