Sha256: 125eb77bd07d540644cbec629fdbf56e1b9fe6e2f42d5ba2f041eca7568f9719

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require "email_spec"

describe 'misc forklift core' do  
  describe 'email' do
    include EmailSpec::Helpers
    include EmailSpec::Matchers

    it "can send mail with an email template" do
      plan = SpecPlan.new
      plan.do! {
        email_args = {
          to:       "YOU@FAKE.com",
          from:     "Forklift",
          subject:  "Forklift has moved your database",
        }
        email_variables = {
          total_users_count: 10,
          new_users_count: 5,
        }
        email_template = "#{File.dirname(__FILE__)}/../../template/spec_email_template.erb"
        @email = plan.mailer.send_template(email_args, email_template, email_variables).first
      }
      plan.disconnect!
      
      expect(@email).to deliver_to("YOU@FAKE.com")
      expect(@email).to have_subject(/Forklift has moved your database/)
      expect(@email).to have_body_text(/Your forklift email/) # base
      expect(@email).to have_body_text(/Total Users: 10/) # template
      expect(@email).to have_body_text(/New Users: 5/) # template
    end

    it "can send mail with an attachment" do 
      skip("how to test email attachments?")
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
forklift_etl-1.2.2 spec/unit/misc/email_spec.rb
forklift_etl-1.2.1 spec/unit/misc/email_spec.rb
forklift_etl-1.2.0 spec/unit/misc/email_spec.rb