Sha256: c8e789aa0b891316ddde4f9954fc2c9ba3e52e26f8bde16116412f3c3378539c

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'
require 'mail'

module Roadie
  module Rails
    describe Automatic do
      base_mailer = Class.new do
        def initialize(email = nil)
          @email = email
        end

        def mail(options = {})
          @email
        end
      end

      some_mailer = Class.new(base_mailer) do
        include Automatic
      end

      describe "#roadie_options" do
        it "returns Rails' roadie config" do
          allow(::Rails).to receive_message_chain(:application, :config, :roadie).and_return "roadie config"
          expect(some_mailer.new.roadie_options).to eq("roadie config")
        end
      end

      describe "#mail" do
        let(:email) { Mail.new(to: "foo@example.com", from: "me@example.com") }
        let(:instance) { some_mailer.new(email) }

        it "extends the email with InlineOnDelivery and assigns roadie options" do
          options = Options.new(url_options: {host: "somehost.com"})
          allow(instance).to receive(:roadie_options).and_return options

          email = instance.mail

          expect(email).to be_kind_of(InlineOnDelivery)
          expect(email.roadie_options).not_to be_nil
          expect(email.roadie_options.url_options).to eq options.url_options
        end

        it "assigns nil roadie options if no options are present" do
          allow(instance).to receive(:roadie_options).and_return nil

          email = instance.mail

          expect(email).to be_kind_of(InlineOnDelivery)
          expect(email.roadie_options).to be_nil
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
roadie-rails-1.2.0 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.1.1 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.1.0 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.1.0.rc2 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.1.0.rc1 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.0.6 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.0.5 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.0.4 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.0.3 spec/lib/roadie/rails/automatic_spec.rb
roadie-rails-1.0.2 spec/lib/roadie/rails/automatic_spec.rb