Sha256: 99921aac709a746442ee740e478293f2ae8de069e14288cae2370b10d367593d

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

require File::expand_path('../../spec_helper', __FILE__)
require 'opbeat'

describe Opbeat::Logger do
  context 'without a backend logger' do
    before do
      allow(Opbeat.configuration).to receive(:logger) { nil }
    end

    it 'should not error' do
      subject.fatal 'fatalmsg'
      subject.error 'errormsg'
      subject.warn 'warnmsg'
      subject.info 'infomsg'
      subject.debug 'debugmsg'
    end
  end

  context 'with a backend logger' do
    before do
      @logger = double('logger')
      allow(Opbeat.configuration).to receive(:logger) { @logger }
    end

    it 'should log fatal messages' do
      expect(@logger).to receive(:fatal).with('** [Opbeat] fatalmsg')
      subject.fatal 'fatalmsg'
    end

    it 'should log error messages' do
      expect(@logger).to receive(:error).with('** [Opbeat] errormsg')
      subject.error 'errormsg'
    end

    it 'should log warning messages' do
      expect(@logger).to receive(:warn).with('** [Opbeat] warnmsg')
      subject.warn 'warnmsg'
    end

    it 'should log info messages' do
      expect(@logger).to receive(:info).with('** [Opbeat] infomsg')
      subject.info 'infomsg'
    end

    it 'should log debug messages' do
      expect(@logger).to receive(:debug).with('** [Opbeat] debugmsg')
      subject.debug 'debugmsg'
    end

    it 'should log messages from blocks' do
      expect(@logger).to receive(:info).with('** [Opbeat] infoblock')
      subject.info { 'infoblock' }
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
kuende-opbeat-2.0.4 spec/opbeat/logger_spec.rb
kuende-opbeat-2.0.3 spec/opbeat/logger_spec.rb
kuende-opbeat-2.0.2 spec/opbeat/logger_spec.rb
kuende-opbeat-2.0.1 spec/opbeat/logger_spec.rb
opbeat-2.0.0 spec/opbeat/logger_spec.rb
opbeat-1.1.1 spec/opbeat/logger_spec.rb
opbeat-1.1.0 spec/opbeat/logger_spec.rb
opbeat-1.0.0 spec/opbeat/logger_spec.rb
opbeat-0.9.2 spec/opbeat/logger_spec.rb