Sha256: 9923e9c287803dc085080995c8b83cf4889ab6c0796372bc8b37a723976deb23

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe Silencer::Rack::Logger do
  let(:app) { lambda { |env| [200, {}, ''] } }

  it 'quiets the log when configured with a silenced path' do
    expect_any_instance_of(::Logger).to receive(:level=).with(::Logger::ERROR)

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

  it 'quiets the log when configured with a regex' do
    expect_any_instance_of(::Logger).to receive(:level=).with(::Logger::ERROR)

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

  it 'quiets the log when passed a custom header "X-SILENCE-LOGGER"' do
    expect_any_instance_of(::Logger).to receive(:level=).with(::Logger::ERROR)

    Silencer::Rack::Logger.new(app).
      call(Rack::MockRequest.env_for("/", 'HTTP_X_SILENCE_LOGGER' => 'true'))
  end

  it 'does not tamper with the response' do
    response = Silencer::Rack::Logger.new(app).
      call(Rack::MockRequest.env_for("/", 'HTTP_X_SILENCE_LOGGER' => 'true'))

    expect(response[0]).to eq(200)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
silencer-1.0.0.rc1 spec/silencer/rack/logger_spec.rb