Sha256: cab26c13257c7c1b5a468bdc6a9eace589213ea3a0ad825a81c5e26c6a036ef9

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

describe StatusCat::Checkers::ActionMailer do

  let(:checker) { StatusCat::Checkers::ActionMailer.new.freeze }

  it_should_behave_like 'a status checker'

  it 'provides configuration' do
    expect(checker.config).to eql(::ActionMailer::Base.smtp_settings)
  end

  it 'constructs a value from the configuration' do
    expected = "#{checker.address}:#{checker.port}"
    expect(checker.value).to eql(expected)
  end

  #############################################################################
  # status

  describe '#status' do

    before(:each) do
      ::ActionMailer::Base.delivery_method = :smtp
    end

    after(:each) do
      ::ActionMailer::Base.delivery_method = :test
    end

    #############################################################################
    # pass

    context 'pass' do

      it 'passes if it can make an SMTP connection' do
        expect(Net::SMTP).to receive(:start)
        checker = StatusCat::Checkers::ActionMailer.new
        expect(checker.status).to be_nil
      end
    end

    #############################################################################
    # fail

    context 'fail' do

      let(:exception) { Net::SMTPAuthenticationError.new }

      it 'returns an error message if it can not make an SMTP connection' do
        expect(Net::SMTP).to receive(:start).and_raise(exception)
        checker = StatusCat::Checkers::ActionMailer.new
        expect(checker.status).to be(exception)
      end

      it 'returns an error message if it can not send a message' do
        smtp = Object.new
        allow(smtp).to receive(:helo).and_raise(exception)
        allow(Net::SMTP).to receive(:start).and_yield(smtp)
        checker = StatusCat::Checkers::ActionMailer.new
        expect(checker.status).to be(exception)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
status_cat-5.2.1 spec/lib/status_cat/checkers/action_mailer_spec.rb
status_cat-5.2.0 spec/lib/status_cat/checkers/action_mailer_spec.rb
status_cat-5.0.2 spec/lib/status_cat/checkers/action_mailer_spec.rb
status_cat-5.0.1 spec/lib/status_cat/checkers/action_mailer_spec.rb
status_cat-5.0.0 spec/lib/status_cat/checkers/action_mailer_spec.rb