diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/answer_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/comment_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/email_answer_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/question_spec.rb | 4 | ||||
-rw-r--r-- | spec/support/delayed_should_receive.rb | 11 |
5 files changed, 18 insertions, 7 deletions
diff --git a/spec/models/answer_spec.rb b/spec/models/answer_spec.rb index 200077d..de72393 100644 --- a/spec/models/answer_spec.rb +++ b/spec/models/answer_spec.rb @@ -141,14 +141,14 @@ describe Answer do #can't use Factory Girl here, because we want to save it after setting expectation to get email answer = Answer.new(:owner => recruit, :question => question, :content => "Some answer.") - UserMailer.should_receive(:send_later).with(:deliver_new_answer, recruit.mentor, answer) + UserMailer.should_receive_delayed(:deliver_new_answer, recruit.mentor, answer) answer.save! end it "should send email notification to mentor when changed" do answer = Factory(:answer) - UserMailer.should_receive(:send_later).with(:deliver_changed_answer, answer.owner.mentor, answer) + UserMailer.should_receive_delayed(:deliver_changed_answer, answer.owner.mentor, answer) answer.content = "changed" answer.save! end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 8a071c6..7b5e5d9 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -49,7 +49,7 @@ describe Comment do answer = Factory(:answer) comment = Comment.new(:owner => answer.owner.mentor, :answer => answer, :content => "some comment") - UserMailer.should_receive(:send_later).with(:deliver_new_comment, answer.owner, comment) + UserMailer.should_receive_delayed(:deliver_new_comment, answer.owner, comment) comment.save! end diff --git a/spec/models/email_answer_spec.rb b/spec/models/email_answer_spec.rb index b452a19..3e7096f 100644 --- a/spec/models/email_answer_spec.rb +++ b/spec/models/email_answer_spec.rb @@ -7,7 +7,7 @@ describe EmailAnswer do mail.subject = "#{question.id + 1}-#{recruit.token}" mail.from = recruit.email_address - UserMailer.should_receive(:send_later).with(:deliver_unrecognized_email, recruit, mail) + UserMailer.should_receive_delayed(:deliver_unrecognized_email, recruit, mail) EmailAnswer.answer_from_email(mail) end @@ -18,7 +18,7 @@ describe EmailAnswer do mail.subject = "#{question.id}-#{recruit.token}" mail.from = recruit.email_address - UserMailer.should_receive(:send_later).with(:deliver_unrecognized_email, recruit, mail) + UserMailer.should_receive_delayed(:deliver_unrecognized_email, recruit, mail) EmailAnswer.answer_from_email(mail) end diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb index b8ff206..0489be4 100644 --- a/spec/models/question_spec.rb +++ b/spec/models/question_spec.rb @@ -71,7 +71,7 @@ describe Question do question = Question.new(:title => "new question", :question_category => category) - UserMailer.should_receive(:send_later).with(:deliver_new_question, recruit, question) + UserMailer.should_receive_delayed(:deliver_new_question, recruit, question) question.save! end @@ -82,7 +82,7 @@ describe Question do question = Factory(:question, :title => "new question", :question_category => category, :user => Factory(:recruit)) - UserMailer.should_receive(:send_later).with(:deliver_new_question, recruit, question) + UserMailer.should_receive_delayed(:deliver_new_question, recruit, question) question.approved = true question.save! end diff --git a/spec/support/delayed_should_receive.rb b/spec/support/delayed_should_receive.rb new file mode 100644 index 0000000..c3a333e --- /dev/null +++ b/spec/support/delayed_should_receive.rb @@ -0,0 +1,11 @@ +class Object + def should_receive_delayed(method, *args) + m = Spec::Mocks::Mock.new('proxy') + if args.empty? + m.should_receive(method) + else + m.should_receive(method).with(*args) + end + self.should_receive(:delay).and_return(m) + end +end |