Salil Gaikwad
2009-Apr-13 15:06 UTC
[rspec-users] how to write a spec for an actionmailer method
how to write a spec for an actionmailer method. following is the method of action controller. class Notifier < ActionMailer::Base def conta(username ,adresseemail,code) @subject = ''Admin Confirmation Mail'' @recipients = adresseemail @body["Username"]= username @body["adresseemail"]= adresseemail @body[:url] = "http://192.168.1.58:3002/login/activate/#{code}" @from =''anubhaw at cipher-tech.com'' @sent_on = Time.now end end Regards Salil -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2009-Apr-13 15:14 UTC
[rspec-users] how to write a spec for an actionmailer method
On Mon, Apr 13, 2009 at 12:06 PM, Salil Gaikwad <lists at ruby-forum.com> wrote:> how to write a spec for an actionmailer method.Check out http://github.com/bmabey/email-spec/ Cheers, David> > following is the method of action controller. > > class Notifier < ActionMailer::Base > > ?def conta(username ,adresseemail,code) > ? ?@subject ?= ''Admin Confirmation Mail'' > ? ?@recipients ?= adresseemail > ? ?@body["Username"]= username > ? ?@body["adresseemail"]= adresseemail > ? ?@body[:url] ?= "http://192.168.1.58:3002/login/activate/#{code}" > ? ?@from ? ? ? ? ? ? ?=''anubhaw at cipher-tech.com'' > ? ?@sent_on ? ? ? ? = ?Time.now > ?end > > end > > Regards > > Salil > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Ben Mabey
2009-Apr-13 15:21 UTC
[rspec-users] how to write a spec for an actionmailer method
David Chelimsky wrote:> On Mon, Apr 13, 2009 at 12:06 PM, Salil Gaikwad <lists at ruby-forum.com> wrote: > >> how to write a spec for an actionmailer method. >> > > Check out http://github.com/bmabey/email-spec/ > > Cheers, > David >Specifically, look at this example for an idea on how to use it with RSpec: http://github.com/bmabey/email-spec/blob/cdf3eeda4d28ef8b35bbce8af9ca7c493528332d/examples/rails_root/spec/models/user_mailer_spec.rb -Ben> >> following is the method of action controller. >> >> class Notifier < ActionMailer::Base >> >> def conta(username ,adresseemail,code) >> @subject = ''Admin Confirmation Mail'' >> @recipients = adresseemail >> @body["Username"]= username >> @body["adresseemail"]= adresseemail >> @body[:url] = "http://192.168.1.58:3002/login/activate/#{code}" >> @from =''anubhaw at cipher-tech.com'' >> @sent_on = Time.now >> end >> >> end >> >> Regards >> >> Salil >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Salil Gaikwad
2009-Apr-14 14:11 UTC
[rspec-users] how to write a spec for an actionmailer method
> http://github.com/bmabey/email-spec/blob/cdf3eeda4d28ef8b35bbce8af9ca7c493528332d/examples/rails_root/spec/models/user_mailer_spec.rb > > -BenI try following and it works. i don''t know how but it pass the test gives me 100% coverage and also i receive a test email. describe ApplicationHelper do it "should use ActionMailer to send a confirmation email" do ActionMailer::Base.deliveries=[] Notifier.deliver_conta(''Salil'',''salil at cipher-tech.com'', 123456) end end -- Posted via http://www.ruby-forum.com/.