Sha256: 725906d9f11111a5838c068b6e34e9facc731d4cb609615a20d0508f9f4858b2

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe FeduxOrg::Stdlib::Logging::Logger do
  context '#new' do
    it 'defaults to ruby logger class' do
      logger = FeduxOrg::Stdlib::Logging::Logger.new
      expect( logger.respond_to? :debug ).to be_true
    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 = FeduxOrg::Stdlib::Logging::Logger.new( log1 )
      expect( logger.instance_variable_get( :@logger ) ).to be_kind_of ::RSpec::Mocks::Mock
      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 = FeduxOrg::Stdlib::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 = FeduxOrg::Stdlib::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

5 entries across 5 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.3.2 spec/logger/logger_spec.rb
fedux_org-stdlib-0.3.0 spec/logger/logger_spec.rb
fedux_org-stdlib-0.2.1 spec/logger/logger_spec.rb
fedux_org-stdlib-0.1.3 spec/logger/logger_spec.rb
fedux_org-stdlib-0.1.2 spec/logger/logger_spec.rb