Sha256: a6cfc4912a6709962b78c66eee97cdb4187870a585ed9ce207847db50fa17225

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

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 200 response code' do
      expect(last_response).to be_ok
    end
    example 'returns no logs because there are no files' do
      expect(last_response.body).to eq ''
    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

3 entries across 3 versions & 1 rubygems

Version Path
rack-logs-0.0.3 spec/integration/running_rack_logs_via_rack_spec.rb
rack-logs-0.0.2 spec/integration/running_rack_logs_via_rack_spec.rb
rack-logs-0.0.1 spec/integration/running_rack_logs_via_rack_spec.rb