This will sound awfully stupid, but i have no idea how to start writing any mailer tests. I have a mailer class class SmsMailer < ActionMailer::Base def fake_sms(envelope) mail(:to => envelope.user.email) end end how do I test this? I tried googling for documentation, but was unable to find something relevant (probable used wrong search terms). Or do i just do view-tests on the corresponding view?
David Chelimsky
2010-Sep-02 15:22 UTC
[rspec-users] rails3/rspec2: how to write mailer tests?
On Sep 2, 2010, at 10:16 AM, nathanvda wrote:> This will sound awfully stupid, but i have no idea how to start > writing any mailer tests. > > I have a mailer class > > class SmsMailer < ActionMailer::Base > > def fake_sms(envelope) > mail(:to => envelope.user.email) > end > end > > how do I test this? > I tried googling for documentation, but was unable to find something > relevant (probable used wrong search terms). > > Or do i just do view-tests on the corresponding view?Start with "script/rails generate rspec:mailer sms" - that will generate a stub for you and you can go from there.
David Chelimsky
2010-Sep-02 15:23 UTC
[rspec-users] rails3/rspec2: how to write mailer tests?
On Sep 2, 2010, at 10:16 AM, nathanvda wrote:> This will sound awfully stupid, but i have no idea how to start > writing any mailer tests. > > I have a mailer class > > class SmsMailer < ActionMailer::Base > > def fake_sms(envelope) > mail(:to => envelope.user.email) > end > end > > how do I test this? > I tried googling for documentation, but was unable to find something > relevant (probable used wrong search terms). > > Or do i just do view-tests on the corresponding view?Start with "script/rails generate rspec:mailer sms" - that will generate a stub for you and you can go from there.
Toni Tuominen
2010-Sep-02 15:24 UTC
[rspec-users] rails3/rspec2: how to write mailer tests?
On Thu, Sep 2, 2010 at 6:16 PM, nathanvda <nathanvda at gmail.com> wrote:> This will sound awfully stupid, but i have no idea how to start > writing any mailer tests. > > I have a mailer class > > ? ?class SmsMailer < ActionMailer::Base > > ? ? ?def fake_sms(envelope) > ? ? ? ?mail(:to => envelope.user.email) > ? ? ?end > ? ?end > > how do I test this? > I tried googling for documentation, but was unable to find something > relevant (probable used wrong search terms). > > Or do i just do view-tests on the corresponding view? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >What you want is http://github.com/bmabey/email-spec.
On Sep 2, 11:24?am, Toni Tuominen <tjt... at utu.fi> wrote:> On Thu, Sep 2, 2010 at 6:16 PM, nathanvda <nathan... at gmail.com> wrote: > > This will sound awfully stupid, but i have no idea how to start > > writing any mailer tests. > > > I have a mailer class > > > ? ?class SmsMailer < ActionMailer::Base > > > ? ? ?def fake_sms(envelope) > > ? ? ? ?mail(:to => envelope.user.email) > > ? ? ?end > > ? ?end > > > how do I test this? > > I tried googling for documentation, but was unable to find something > > relevant (probable used wrong search terms). > > > Or do i just do view-tests on the corresponding view? > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > What you want ishttp://github.com/bmabey/email-spec. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users+1 for the email-spec gem
> > Start with "script/rails generate rspec:mailer sms" - that will generate a stub for you and you can go from there.I am sorry if that was not clear, but i am using rspec2 and rails. I did use "rails g mailer SomethingMailer" and that produced an empty test. But when i did "rails g mailer SomethingMailer some_mail" i got a good example. Feels stupid again :)