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.6.54 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.53 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.52 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.51 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.50 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.48 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.47 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.46 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.45 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.44 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.43 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.40 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.39 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.38 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.37 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.34 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.33 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.32 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.31 spec/logger/logger_spec.rb
fedux_org-stdlib-0.6.30 spec/logger/logger_spec.rb