Skip to content
This repository
Browse code

Rack::Logger conforms to Rack::Lint, closes Lighthouse #89

  • Loading branch information...
commit f76e1bae9eac1cbb1e7b0b2846e6a0f8e42f9256 1 parent 623a5fb
James Tucker raggi authored

Showing 2 changed files with 16 additions and 10 deletions. Show diff stats Hide diff stats

  1. +0 2  lib/rack/logger.rb
  2. +16 8 test/spec_logger.rb
2  lib/rack/logger.rb
@@ -13,8 +13,6 @@ def call(env)
13 13
14 14 env['rack.logger'] = logger
15 15 @app.call(env)
16   - ensure
17   - logger.close
18 16 end
19 17 end
20 18 end
24 test/spec_logger.rb
@@ -2,19 +2,27 @@
2 2 require 'rack/logger'
3 3
4 4 describe Rack::Logger do
5   - should "log to rack.errors" do
6   - app = lambda { |env|
7   - log = env['rack.logger']
8   - log.debug("Created logger")
9   - log.info("Program started")
10   - log.warn("Nothing to do!")
  5 + app = lambda { |env|
  6 + log = env['rack.logger']
  7 + log.debug("Created logger")
  8 + log.info("Program started")
  9 + log.warn("Nothing to do!")
11 10
12   - [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
13   - }
  11 + [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
  12 + }
14 13
  14 + should "log to rack.errors" do
15 15 errors = StringIO.new
16 16 Rack::Logger.new(app).call('rack.errors' => errors)
17 17 errors.string.should.match(/INFO -- : Program started/)
18 18 errors.string.should.match(/WARN -- : Nothing to do/)
19 19 end
  20 +
  21 + should "conform to Rack::Lint" do
  22 + errors = StringIO.new
  23 + a = Rack::Lint.new(Rack::Logger.new(app))
  24 + Rack::MockRequest.new(a).get('/', 'rack.errors' => errors)
  25 + errors.string.should.match(/INFO -- : Program started/)
  26 + errors.string.should.match(/WARN -- : Nothing to do/)
  27 + end
20 28 end

0 comments on commit f76e1ba

Please sign in to comment.
Something went wrong with that request. Please try again.