rack.git  about / heads / tags
a modular Ruby webserver interface
blob d55b9c777e092ec0d76cfebc51ac7b6cf9bce3b3 563 bytes (raw)
$ git show rack.io:test/spec_rack_logger.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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

git clone https://yhbt.net/rack.git