summary refs log tree commit
path: root/test/spec_rack_logger.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/spec_rack_logger.rb')
-rw-r--r--test/spec_rack_logger.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/spec_rack_logger.rb b/test/spec_rack_logger.rb
new file mode 100644
index 00000000..d55b9c77
--- /dev/null
+++ b/test/spec_rack_logger.rb
@@ -0,0 +1,21 @@
+require 'rack/logger'
+require 'rack/lint'
+require 'stringio'
+
+context "Rack::Logger" do
+  specify "logs to rack.errors" 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!"]]
+    }
+
+    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
+end