Sha256: fb389d6b9f88fe6495c166fa5667d00834c2a9078e96b3a1a77279d5c1f6542d

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'fileutils'

describe Low::Middleware::RackErrors do
  def test_app
    lambda do |env|
      [200, {'Content-Type' => 'text/plain'}, env['rack.errors']]
    end
  end

  after(:each) do
    ENV['RACK_ENV'] = 'test'
  end

  it 'should log to the FS in the development RACK_ENV by default' do
    ENV['RACK_ENV'] = 'development'
    rack = Low::Middleware::RackErrors.new test_app
    response = rack.call({})
    response[2].path.should == 'log/development.log'
  end

  it 'should log to the FS in the test RACK_ENV by default' do
    ENV['RACK_ENV'] = 'test'
    rack = Low::Middleware::RackErrors.new test_app
    response = rack.call({})
    response[2].path.should == 'log/test.log'
  end

  it 'should log to the FS in the specified RACK_ENV' do
    ENV['RACK_ENV'] = 'production'
    rack = Low::Middleware::RackErrors.new test_app, fs_envs: ['production']
    response = rack.call({})
    response[2].path.should == 'log/production.log'
  end

  it 'should log to STDOUT if not in a specified RACK_ENV' do
    ENV['RACK_ENV'] = 'production'
    rack = Low::Middleware::RackErrors.new test_app
    response = rack.call({})
    response[2].should == STDOUT
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
low-0.0.12 spec/low/middleware/rack_errors_spec.rb
low-0.0.11 spec/low/middleware/rack_errors_spec.rb