Sha256: c2729457dc0482fb6b13882a8059f22eb76d442e27295423a73ac01d296adc90

Contents?: true

Size: 1.5 KB

Versions: 64

Compression:

Stored size: 1.5 KB

Contents

# encoding: utf-8
require 'spec_helper'

RSpec.describe FeduxOrgStdlib::Logging::Logger do
  context '#new' do
    it 'defaults to ruby logger class' do
      logger = FeduxOrgStdlib::Logging::Logger.new
      expect(logger.respond_to? :debug).to be_truthy
    end
  end

  context '#reset' do
    it '_resets_ the logger to the ruby logger' do
      log1 = double('Logger')
      allow(log1).to receive(:level=)
      allow(log1).to receive(:formatter=)

      logger = FeduxOrgStdlib::Logging::Logger.new(log1)
      expect(logger.instance_variable_get(:@logger)).to be_kind_of ::RSpec::Mocks::Double
      logger.reset
      expect(logger.instance_variable_get(:@logger)).to be_kind_of ::Logger 
    end
  end

  context '#mode=' do
    it 'defaults to info mode' do
      bucket = StringIO.new

      logger = FeduxOrgStdlib::Logging::Logger.new(Logger.new(bucket))
      logger.debug 'Not visible'
      logger.info 'Visible'

      expect(bucket.string).to include('Visible')
      expect(bucket.string).not_to include('Not visible')
    end

    it 'changes the mode (log level) of the logger' do
      bucket = StringIO.new

      logger = FeduxOrgStdlib::Logging::Logger.new(Logger.new(bucket))
      logger.debug 'Not visible Debug'
      logger.info 'Visible Info'
      logger.mode = :debug
      logger.debug 'Visible Debug'

      expect(bucket.string).not_to include('Not visible Debug')
      expect(bucket.string).to include('Visible Info')
      expect(bucket.string).to include('Visible Debug')
    end

  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.7.21 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.20 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.19 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.18 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.17 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.16 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.15 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.14 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.12 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.11 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.10 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.8 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.7 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.6 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.5 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.4 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.3 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.2 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.1 spec/logger/logger_spec.rb
fedux_org-stdlib-0.7.0 spec/logger/logger_spec.rb