Hello, I'm back again with more questions about mocks and how to do good testing in general. Let's say I'm writing this EmailSender class and I want to make it totally awesomely tested with RSpec. Here's how far I've gotten so far:
require 'net/smtp' class EmailSender def send_email mailer.start('your.smtp.server', 25) do |smtp| smtp.send_message("Yay! You got an email!", '[EMAIL PROTECTED]', '[EMAIL PROTECTED]') end def def mailer Net::SMTP end end 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 MockSMTP.should_receive(:start).with('your.smtp.server', 25) #but, er...wha? end end So - not sure how to validate the part where "send_message" is called. Is there a recommended way of doing this? -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users