Sha256: 373ef427df3ada0fe8cc53348984d7c3b43e32b4d32c7eecd78badb05b0fd2fe

Contents?: true

Size: 980 Bytes

Versions: 2

Compression:

Stored size: 980 Bytes

Contents

require 'rack/test'
require 'rack/logs'

describe 'running `Rack::Logs` via `Rack::Builder`', type: :integration do
  include Rack::Test::Methods

  context 'running with defaults' do
    let(:app) { Rack::Builder.app { run Rack::Logs } }

    before { get '/' }

    example 'returns a 404 response code because there are no files' do
      expect(last_response.status).to eq 404
    end
  end

  context 'given a log in a configured directory' do
    let(:app) do
      Rack::Builder.app do
        logs = Rack::Logs.configure do |config|
          config.log_dir = './tmp'
        end
        run logs
      end
    end

    before do
      File.open('./tmp/my_log_file.log','w') do |f|
        f.write "LOG ENTRY 1234"
      end
      get '/'
    end

    example 'returns a 200 response code' do
      expect(last_response).to be_ok
    end

    example 'accessing the log returns log contents' do
      expect(last_response.body).to match 'LOG ENTRY 1234'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-logs-0.0.5 spec/integration/running_rack_logs_via_rack_spec.rb
rack-logs-0.0.4 spec/integration/running_rack_logs_via_rack_spec.rb