Sha256: 6d739b77d99998414353a03ec3c34734ec2d663eabeaadcb062f968f72347c2f

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

require 'spec_helper'

module SinatraTest
  describe 'ignoring rack cascade 404s' do
    DRAIN = StringIO.new
    LOGGER = Logger.new(DRAIN)

    before do
      DRAIN.truncate(0)
    end
    let(:drain) { DRAIN } # for shared helpers

    class Base < Sinatra::Base
      use Rack::KeyValueLogger, :logger => LOGGER
    end

    class FirstApp < Base
      get('/other') { status(200) }
    end

    class SecondApp < Base
      get('/success') { status(200) }
    end

    let(:app) do
      Rack::Builder.app do
        run Rack::Cascade.new([FirstApp, SecondApp])
      end
    end

    before do
      do_get '/success'
    end

    it_behaves_like 'it logs', 'status', '200'
    it_behaves_like 'it logs', 'url', '/success'
    it_behaves_like 'it does not log', 'status', '404'

    it 'should only log one entry' do
      drain.rewind
      drain.lines.count.should == 1
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-key_value_logger-0.4.1 spec/integration/sinatra_spec.rb
rack-key_value_logger-0.4.0 spec/integration/sinatra_spec.rb
rack-key_value_logger-0.3.1 spec/integration/sinatra_spec.rb