开发者

RSpec should_receive macro that includes id of what needs to be tested

开发者 https://www.devze.com 2023-04-04 05:31 出处:网络
How can I write this so it passes without hardcoding 1. Chicken and the egg. @sender = Factory(:user) @receiver = Factory(:user)

How can I write this so it passes without hardcoding 1. Chicken and the egg.

@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
@obj开发者_JAVA百科ect = Object.create(:sender => @sender, :receiver => @receiver)


How about this?

Mailer.should_receive(:email).with(an_instance_of(Fixnum), @sender.id, @receiver.id).and_return(mailer)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号