Sha256: 6f326e059d10ee0635b2ac781c55d18132943d469cbb8ef7a3185ec402a26bbb

Contents?: true

Size: 1.63 KB

Versions: 13

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'mail'

module Roadie
  module Rails
    describe Mailer do
      some_mailer = Class.new do
        include Mailer

        def initialize(email = nil)
          @email = email
        end

        def mail(options = {})
          @email
        end
      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 "#roadie_mail" do
        let(:email) { Mail.new }
        let(:instance) { some_mailer.new(email) }

        before { allow(instance).to receive(:roadie_options).and_return(Options.new) }

        before do
          inliner = double "Mail inliner"
          allow(inliner).to receive(:execute) { |email| email }
          allow(MailInliner).to receive(:new).and_return(inliner)
        end

        it "calls the original mail method with all options and the block" do
          expect(instance).to receive(:mail) do |options, &block|
            expect(options).to eq({some: "option"})
            expect(block).not_to be_nil
            email
          end

          instance.roadie_mail(some: "option") { }
        end

        it "inlines the email" do
          inliner = double "Inliner"
          expect(MailInliner).to receive(:new).with(email, instance_of(Options)).and_return inliner
          expect(inliner).to receive(:execute).and_return "inlined email"
          expect(instance.roadie_mail).to eq("inlined email")
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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