RSpec should_receive macro that includes id of what needs to be tested
我怎样才能写出这样它才能通过而不用硬编码
1 2 3 4 5 6 7 8 9 | @sender = Factory(:user) @receiver = Factory(:user) mailer = double mailer.should_receive(:deliver) Mailer.should_receive(:email).with(1, @sender.id, @receiver.id).and_return(mailer) # This will create an object with id #1 to make this test pass @object = Object.create(:sender => @sender, :receiver => @receiver) |
这个怎么样?
1 | Mailer.should_receive(:email).with(an_instance_of(Fixnum), @sender.id, @receiver.id).and_return(mailer) |