Sha256: c8465b15f626c37f873d9a73e3d6f70f031446721139b4f65c91021fcaa190ea

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Silencer::Logger do
  before(:each) do
    @app = lambda { |env| [200, {}, ''] }

    Rails.logger = ActiveSupport::BufferedLogger.new('tmp/test.log')
  end

  it 'allows log writing when not implemented' do
    Rails.logger.should_not_receive(:silence)
    Rails.logger.should_receive(:info).at_least(:once)

    Silencer::Logger.new(@app).call(Rack::MockRequest.env_for("/"))
  end

  it 'quiets the log when configured with a silenced path' do
    Rails.logger.should_receive(:silence)
    Rails.logger.should_not_receive(:info)

    Silencer::Logger.new(@app, :silence => ['/']).call(Rack::MockRequest.env_for("/"))
  end

  it 'quiets the log when passed a custom header "X-SILENCE-LOGGER"' do
    Rails.logger.should_receive(:silence)
    Rails.logger.should_not_receive(:info)

    Silencer::Logger.new(@app).call(Rack::MockRequest.env_for("/", 'X-SILENCE-LOGGER' => 'true'))
  end

  it 'does not tamper with the response' do
    response = Silencer::Logger.new(@app).call(Rack::MockRequest.env_for("/", 'X-SILENCE-LOGGER' => 'true'))
    response[0].should eq(200)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
silencer-0.0.1 spec/silencer_spec.rb