summary refs log tree commit
diff options
context:
space:
mode:
authorraggi <jftucker@gmail.com>2010-10-03 22:09:13 -0300
committerJames Tucker <jftucker@gmail.com>2011-05-23 00:07:27 -0700
commit51cdaa62f5212976831535cac32e2ae5d00bafe1 (patch)
treebf1f395df48a9545a939e65338e8d1a94c183955
parent5aa4a33a92b768331c03244e896fdad66bb4cf52 (diff)
downloadrack-51cdaa62f5212976831535cac32e2ae5d00bafe1.tar.gz
Rack::Logger conforms to Rack::Lint, closes Lighthouse #89
-rw-r--r--lib/rack/logger.rb2
-rw-r--r--test/spec_logger.rb24
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/rack/logger.rb b/lib/rack/logger.rb
index d67d8ce2..88f9837d 100644
--- a/lib/rack/logger.rb
+++ b/lib/rack/logger.rb
@@ -13,8 +13,6 @@ module Rack
 
       env['rack.logger'] = logger
       @app.call(env)
-    ensure
-      logger.close
     end
   end
 end
diff --git a/test/spec_logger.rb b/test/spec_logger.rb
index f1952273..f9e79739 100644
--- a/test/spec_logger.rb
+++ b/test/spec_logger.rb
@@ -2,19 +2,27 @@ require 'stringio'
 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