Sha256: fefd0172d7bda20511049a0783396a1203427395711913a7c5923dc523a1ddf2

Contents?: true

Size: 1.19 KB

Versions: 21

Compression:

Stored size: 1.19 KB

Contents

require 'watirspec_helper'

module Watir
  describe Logger do
    around do |example|
      debug = $DEBUG
      $DEBUG = false
      example.call
      $DEBUG = debug
      Watir.instance_variable_set(:@logger, nil) # reset cache
    end

    it 'logs warnings by default' do
      expect(Watir.logger.level).to eq(2)
    end

    it 'logs everything if $DEBUG is set to true' do
      $DEBUG = true
      expect(Watir.logger.level).to eq(0)
    end

    it 'allows to change level during execution' do
      Watir.logger.level = :info
      expect(Watir.logger.level).to eq(1)
    end

    it 'outputs to stdout by default' do
      expect { Watir.logger.warn('message') }.to output(/WARN Watir message/).to_stdout
    end

    it 'allows to output to file' do
      begin
        Watir.logger.output = 'test.log'
        Watir.logger.warn('message')
        expect(File.read('test.log')).to include('WARN Watir message')
      ensure
        File.delete('test.log')
      end
    end

    it 'allows to deprecate functionality' do
      message = /WARN Watir \[DEPRECATION\] #old is deprecated\. Use #new instead\./
      expect { Watir.logger.deprecate('#old', '#new') }.to output(message).to_stdout
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
watir-6.11.0 spec/logger_spec.rb
watir-6.11.0.beta2 spec/logger_spec.rb
watir-6.11.0.beta1 spec/logger_spec.rb
watir-6.10.3 spec/logger_spec.rb
watir-6.10.2 spec/logger_spec.rb
watir-6.10.0 spec/logger_spec.rb
watir-6.9.1 spec/logger_spec.rb
watir-6.9.0 spec/logger_spec.rb
watir-6.8.4 spec/logger_spec.rb
watir-6.8.3 spec/logger_spec.rb
watir-6.8.2 spec/logger_spec.rb
watir-6.8.1 spec/logger_spec.rb
watir-6.8.0 spec/logger_spec.rb
watir-6.7.3 spec/logger_spec.rb
watir-6.7.2 spec/logger_spec.rb
watir-6.7.1 spec/logger_spec.rb
watir-6.7.0 spec/logger_spec.rb
watir-6.6.3 spec/logger_spec.rb
watir-6.6.2 spec/logger_spec.rb
watir-6.6.1 spec/logger_spec.rb