Testing Mailers with RSpec

Standard

Important Gems:

1)E-mail Spec

2)Shoulda

3)Shoulda Matchers

Example:

email = UserMailer.create_signup("jojo@yahoo.com", "Jojo Binks")
email.should reply_to("support@myapp.com")

Sending e-mails successfully

it "Should send e-mails successfully" do
        lambda { RegistrationMailer.register(@clients) }.should_not raise_error
 end
it "Should send e-mail to alll admins" do
        admin_emails = Array.new
        @produts.each do |produt|
          produt.company.adminis.each do |admin|
            admins_emails << admin.email
          end
        end
        
        lambda { SalesMailer.send_all(@products).should deliver_to(admins_emails) }
      end
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s