I''m spec''ing a model with an observer that sends mail. Mailers behave similarly to controllers, so to make the whole thing work, I believe something like integrate_views has to be available. Has anyone dealt with observers and ActionMailer? Thanks
Jonathan Tron
2007-Jan-19 09:09 UTC
[rspec-users] spec''ing models with observers that send mail
Le 18 janv. 07 ? 22:44, s.ross a ?crit :> I''m spec''ing a model with an observer that sends mail. Mailers behave > similarly to controllers, so to make the whole thing work, I believe > something like integrate_views has to be available. Has anyone dealt > with observers and ActionMailer?I did it to add specs to restful_authentication plugin, it uses an observer to send mail on signup/activation. For the observer, I choosed to get it by calling UserObserver.instance and then spec from that with a mock User object. (cf: http://jonathan.tron.name/files/user_observer_spec.v2.rb) For the mailer, I choosed to spec based on the different mailer actions and what UserNotifier.create_my_action returns. (cf: http:// jonathan.tron.name/files/user_notifier_spec.v2.rb) I''m not sure it''s the right way to go, especially for the mailer part, so feel free to correct my mistakes. Jonathan -- Tron Jonathan http://jonathan.tron.name