From 9b46379f75f384c86e42046ab03ce55231197c92 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Dec 2010 13:23:32 -0800 Subject: accept a new :path argument in initialize This lessens confusion for people configuring Clogger in config.ru, since "File" could be mistaken for Rack::File and "::File" needs to be specified. --- test/test_clogger.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/test_clogger.rb b/test/test_clogger.rb index 1311017..9252a42 100644 --- a/test/test_clogger.rb +++ b/test/test_clogger.rb @@ -3,6 +3,7 @@ $stderr.sync = $stdout.sync = true require "test/unit" require "date" require "stringio" +require "tempfile" require "rack" @@ -629,4 +630,21 @@ class TestClogger < Test::Unit::TestCase end end if RUBY_PLATFORM =~ /linux/ && File.readable?(LINUX_PROC_PID_STATUS) + def test_path_open_file + tmp = Tempfile.new('test_clogger') + app = lambda { |env| [ 200, {}, [] ] } + app = Clogger.new(app, :format => '$status', :path => tmp.path) + assert_kind_of Integer, app.fileno + assert app.fileno != tmp.fileno + status, headers, body = app.call(@req) + assert_equal "200\n", tmp.read + end + + def test_path_logger_conflict + tmp = Tempfile.new('test_clogger') + app = lambda { |env| [ 200, {}, [] ] } + assert_raises(ArgumentError) { + Clogger.new(app, :logger=> $stderr, :path => tmp.path) + } + end end -- cgit v1.2.3-24-ge0c7