Sha256: a00e3acf6ac21f9bcd1e1fbcf41dc7c5a32cbbbc42f94a629cd3077eeacb4c4f

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe NotificationMailer do
  before do
    @entity1 = Factory(:user)
    @entity2 = Factory(:duck)
    @entity3 = Factory(:cylon)
    @receipt1 = Notification.notify_all([@entity1,@entity2,@entity3],"Subject", "Body Body Body Body Body Body Body Body Body Body Body Body")
  end

  it "should send emails when should_email? is true (2 out of 3)" do
    ActionMailer::Base.deliveries.empty?.should==false
    ActionMailer::Base.deliveries.size.should==2
  end

  it "should send an email to user entity" do
    temp = false
    ActionMailer::Base.deliveries.each do |email|
      if email.to.first.to_s.eql? @entity1.email
      temp = true
      end
    end
    temp.should==true
  end

  it "should send an email to duck entity" do
    temp = false
    ActionMailer::Base.deliveries.each do |email|
      if email.to.first.to_s.eql? @entity2.email
      temp = true
      end
    end
    temp.should==true
  end

  it "shouldn't send an email to cylon entity" do
    temp = false
    ActionMailer::Base.deliveries.each do |email|
      if email.to.first.to_s.eql? @entity3.email
      temp = true
      end
    end
    temp.should==false
  end
end

def print_emails
  ActionMailer::Base.deliveries.each do |email|
      puts "----------------------------------------------------"
      puts email.to
      puts "---"
      puts email.from
      puts "---"
      puts email.subject
      puts "---"
      puts email.body
      puts "---"
      puts email.encoded
      puts "----------------------------------------------------"
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mailboxer-0.6.5 spec/mailers/notification_mailer_spec.rb
mailboxer-0.6.4 spec/mailers/notification_mailer_spec.rb
mailboxer-0.6.3 spec/mailers/notification_mailer_spec.rb
mailboxer-0.6.2 spec/mailers/notification_mailer_spec.rb
mailboxer-0.6.1 spec/mailers/notification_mailer_spec.rb