[rspec-users] The RSpec way of doing this? Need help on validating block

Pat Maddox pergesu at gmail.com
Thu Dec 4 12:52:35 EST 2008


Glad I could help!

"Sebastian W." <lists at ruby-forum.com> writes:

> Ha! Don't I feel silly. Just figured it out, I think.
>
> Sebastian W. wrote:
>> Yikes, left out the all-important call:
>> 
>>> describe EmailSender do
>>>   it "Should use Net::SMTP to send email"
>>>     es = EmailSender.new
>>>     es.mailer.should == Net::SMTP
>>>     MockSMTP = mock("Net::SMTP")
>>>     def es.mailer
>>>       MockSMTP
>>>     end
>        mock_smtp = mock("smtp")
>        MockSMTP.should_receive(:start).with('your.smtp.server', 
> 25).and_yield(mock_smtp)
>        mock_smtp.should_recieve(:send_message).with("Yay! You got an 
> email!", 'your at mail',
> 'other at mail')
>>       es.send_email
>>>   end
>>> end
>
> Mission accomplished. :P


More information about the rspec-users mailing list