Sha256: 8ff345395f5cc1e8a5c8b51c94ba00c7d937e432dfd9cff60dd8892949d88b09

Contents?: true

Size: 1.52 KB

Versions: 55

Compression:

Stored size: 1.52 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(logger: 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: 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: 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

55 entries across 55 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.10.6 spec/logger/logger_spec.rb
fedux_org-stdlib-0.10.5 spec/logger/logger_spec.rb
fedux_org-stdlib-0.10.4 spec/logger/logger_spec.rb
fedux_org-stdlib-0.10.3 spec/logger/logger_spec.rb
fedux_org-stdlib-0.10.2 spec/logger/logger_spec.rb
fedux_org-stdlib-0.10.1 spec/logger/logger_spec.rb
fedux_org-stdlib-0.10.0 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.8 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.7 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.6 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.5 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.4 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.2 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.1 spec/logger/logger_spec.rb
fedux_org-stdlib-0.9.0 spec/logger/logger_spec.rb
fedux_org-stdlib-0.8.11 spec/logger/logger_spec.rb
fedux_org-stdlib-0.8.10 spec/logger/logger_spec.rb
fedux_org-stdlib-0.8.9 spec/logger/logger_spec.rb
fedux_org-stdlib-0.8.8 spec/logger/logger_spec.rb
fedux_org-stdlib-0.8.7 spec/logger/logger_spec.rb