Sha256: 433d9ed68d6567ce9f7a99f91b318e84da935d8dd97ce3a0fab02cbce5374186

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'
require 'mail_room/delivery/logger'

describe MailRoom::Delivery::Logger do
  describe '#initialize' do
    context "without a log path" do
      let(:mailbox) {build_mailbox}

      it 'creates a new ruby logger' do
        ::Logger.stubs(:new)

        MailRoom::Delivery::Logger.new(mailbox)

        expect(::Logger).to have_received(:new).with(STDOUT)
      end
    end

    context "with a log path" do
      let(:mailbox) {build_mailbox(:log_path => '/var/log/mail-room.log')}

      it 'creates a new file to append to' do
        ::Logger.stubs(:new)
        file = stub(:sync=)
        ::File.stubs(:open).returns(file)

        MailRoom::Delivery::Logger.new(mailbox)

        expect(File).to have_received(:open).with('/var/log/mail-room.log', 'a')
        expect(::Logger).to have_received(:new).with(file)
      end
    end
  end

  describe '#deliver' do
    let(:mailbox) {build_mailbox}

    it 'writes the message to info' do
      logger = stub(:info)
      ::Logger.stubs(:new).returns(logger)

      MailRoom::Delivery::Logger.new(mailbox).deliver('a message')

      expect(logger).to have_received(:info).with('a message')
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
gitlab-mail_room-0.0.4 spec/lib/delivery/logger_spec.rb
gitlab-mail_room-0.0.3 spec/lib/delivery/logger_spec.rb
gitlab-mail_room-0.0.2 spec/lib/delivery/logger_spec.rb
mail_room-0.10.0 spec/lib/delivery/logger_spec.rb