[rspec-users] spec'ing models with observers that send mail
jonathan.tron.mailings at gmail.com
Fri Jan 19 04:09:50 EST 2007
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://
I'm not sure it's the right way to go, especially for the mailer
part, so feel free to correct my mistakes.
More information about the rspec-users