tests: add full URL example
authorEric Wong <normalperson@yhbt.net>
Thu, 12 May 2011 01:54:47 +0000 (11 18:54 -0700)
committerEric Wong <normalperson@yhbt.net>
Thu, 12 May 2011 01:57:43 +0000 (11 18:57 -0700)
Could be useful for some folks.

test/test_clogger.rb

index 9440d74..35a211a 100644 (file)
@@ -28,6 +28,7 @@ class TestClogger < Test::Unit::TestCase
       "QUERY_STRING" => "goodbye=true",
       "rack.errors" => $stderr,
       "rack.input" => File.open('/dev/null', 'rb'),
+      "rack.url_scheme" => "http",
       "REMOTE_ADDR" => 'home',
     }
   end
@@ -795,4 +796,16 @@ class TestClogger < Test::Unit::TestCase
     assert_equal :PONIES, s[1]
     assert_equal 2, s.size
   end
+
+  def test_full_uri
+    s = []
+    format = '"$request_method ' \
+             '$env{rack.url_scheme}://$http_host$request_uri $http_version"'
+    app = lambda { |env| [200, [], [] ] }
+    cl = Clogger.new(app, :logger => s, :format => format)
+    @req["HTTP_HOST"] = "example.com"
+    status, headers, body = cl.call(@req)
+    expect = "\"GET http://example.com/hello?goodbye=true HTTP/1.0\"\n"
+    assert_equal [ expect ], s
+  end
 end