Sha256: 35cb3f7595587c46c4884889e6f834e433d054e21cb7ffedc49065dedaa3d6ff

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

require "spec_helper"

describe CapGun do
  describe "mail settings" do
    it "raises if don't have a cap gun email envelope" do
      capistrano = double(
        :cap_gun_action_mailer_config => {},
        :exists? => false
      ).as_null_object

      lambda {
        CapGun::Mailer.load_mailer_config(capistrano)
      }.should raise_error(ArgumentError)
    end

    it "raises if we don't have at least one recipient" do
      capistrano = double(
        :cap_gun_action_mailer_config => {},
        :cap_gun_email_envelope => {}
      ).as_null_object

      lambda {
        CapGun::Mailer.load_mailer_config(capistrano)
      }.should raise_error(ArgumentError)

      capistrano = double(
        :cap_gun_action_mailer_config => {},
        :cap_gun_email_envelope => {
          :recipients => []
        }
      ).as_null_object

      lambda {
        CapGun::Mailer.load_mailer_config(capistrano)
      }.should raise_error(ArgumentError)
    end
  end

  describe CapGun::Mailer do
    describe "deployment_notification" do
      it "builds the correct mail object" do
        capistrano = {
          :cap_gun_email_envelope => {
            :recipients => ["joe@example.com"],
            :from       => "me@example.com"
          }
        }

        presenter = CapGun::Presenter.new(capistrano)
        mail = CapGun::Mailer.deployment_notification(capistrano)
        mail.to.should      == presenter.recipients
        mail.from.should    == [presenter.from] # yes, Mail gem returns an array here
        mail.subject.should == presenter.subject
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xing-cap_gun-0.3.2 spec/cap_gun_spec.rb
xing-cap_gun-0.3.1 spec/cap_gun_spec.rb
xing-cap_gun-0.3.0 spec/cap_gun_spec.rb
xing-cap_gun-0.3.0.pre spec/cap_gun_spec.rb