Sha256: 85ac2798a9b9d6faa3ece13b8ce118174cb5df7d17770cfdd22f3275998cced4

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

describe SlackRubyBot::Loggable do
  let!(:class_with_logger)       { Class.new SlackRubyBot::Commands::Base }
  let!(:child_class_with_logger) { Class.new class_with_logger }
  describe 'logger for class' do
    context 'set logger by config' do
      let(:logger) { double 'logger' }
      it do
        SlackRubyBot.configure do |config|
          config.logger = logger
        end
        expect(class_with_logger.logger).to eq logger
        expect(child_class_with_logger.logger).to eq logger
      end
    end
    context 'default logger' do
      it do
        expect(class_with_logger.logger).to be_kind_of Logger
        expect(child_class_with_logger.logger).to be_kind_of Logger
      end
    end
    it 'should be cached' do
      first_logger = class_with_logger.logger
      second_logger = class_with_logger.logger
      expect(first_logger.object_id).to eq second_logger.object_id
    end
    it 'should not be shared by a child class' do
      first_logger = class_with_logger.logger
      second_logger = child_class_with_logger.logger
      expect(first_logger.object_id).to_not eq second_logger.object_id
    end
  end
  describe 'logger for instance' do
    it 'same with one for class' do
      expect(class_with_logger.new.logger.object_id).to eq class_with_logger.logger.object_id
      expect(child_class_with_logger.new.logger.object_id).to eq child_class_with_logger.logger.object_id
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
slack-ruby-bot-0.12.0 spec/slack-ruby-bot/support/loggable_spec.rb
slack-ruby-bot-0.11.2 spec/slack-ruby-bot/support/loggable_spec.rb
slack-ruby-bot-0.11.1 spec/slack-ruby-bot/support/loggable_spec.rb
slack-ruby-bot-0.11.0 spec/slack-ruby-bot/support/loggable_spec.rb
slack-ruby-bot-0.10.5 spec/slack-ruby-bot/support/loggable_spec.rb
slack-ruby-bot-0.10.4 spec/slack-ruby-bot/support/loggable_spec.rb