On 16 Aug 2011, at 17:30, Jason R. wrote: > Chris M. wrote in post #1014770: >> CurriculumCommentMailer.should_receive(:comment_update).and_return(double("mailer").stub(:deliver)) >> >> That's odd -- I would expect that second version to work if the first >> version is working. What error did you get? Was it the same "undefined >> method `deliver' for nil:NilClass" as before? > > It was giving this error: > NoMethodError: undefined method `deliver' for > #<RSpec::Mocks::MessageExpectation:0x10542bb88> > > But, I changed the test to this and it works fine: > CurriculumCommentMailer.should_receive(:comment_update).and_return(double("mailer", > :deliver => true))
Ah, of course! Because #stub doesn't return the object whose method you're stubbing, it returns a message expectation. I should have spotted that… Chris _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users