Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit f76e1bae9eac1cbb1e7b0b2846e6a0f8e42f9256 1 parent 623a5fb
@raggi raggi authored
Showing with 16 additions and 10 deletions.
  1. +0 −2  lib/rack/logger.rb
  2. +16 −8 test/spec_logger.rb
View
2  lib/rack/logger.rb
@@ -13,8 +13,6 @@ def call(env)
env['rack.logger'] = logger
@app.call(env)
- ensure
- logger.close
end
end
end
View
24 test/spec_logger.rb
@@ -2,19 +2,27 @@
require 'rack/logger'
describe Rack::Logger do
- should "log to rack.errors" do
- app = lambda { |env|
- log = env['rack.logger']
- log.debug("Created logger")
- log.info("Program started")
- log.warn("Nothing to do!")
+ app = lambda { |env|
+ log = env['rack.logger']
+ log.debug("Created logger")
+ log.info("Program started")
+ log.warn("Nothing to do!")
- [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
- }
+ [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
+ }
+ should "log to rack.errors" do
errors = StringIO.new
Rack::Logger.new(app).call('rack.errors' => errors)
errors.string.should.match(/INFO -- : Program started/)
errors.string.should.match(/WARN -- : Nothing to do/)
end
+
+ should "conform to Rack::Lint" do
+ errors = StringIO.new
+ a = Rack::Lint.new(Rack::Logger.new(app))
+ Rack::MockRequest.new(a).get('/', 'rack.errors' => errors)
+ errors.string.should.match(/INFO -- : Program started/)
+ errors.string.should.match(/WARN -- : Nothing to do/)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.