test/unit/logging_tests.rb in deas-0.42.0 vs test/unit/logging_tests.rb in deas-0.43.0
- old
+ new
@@ -5,15 +5,15 @@
class UnitTests < Assert::Context
desc "Deas::Logging"
subject{ Deas::Logging }
- should have_imeths :middleware
+ should have_imeths :middleware_args
- should "return a middleware class given a verbose flag" do
- assert_equal Deas::VerboseLogging, subject.middleware(true)
- assert_equal Deas::SummaryLogging, subject.middleware(false)
+ should "return middleware args given a verbose flag" do
+ assert_equal [Deas::VerboseLogging], subject.middleware_args(true)
+ assert_equal [Deas::SummaryLogging], subject.middleware_args(false)
end
end
class CallSetupTests < UnitTests
@@ -203,13 +203,15 @@
class SummaryLoggingInitTests < SummaryLoggingTests
desc "when init"
setup do
@params = { Factory.string => Factory.string }
+ @splat = Factory.string
@handler_class = TestHandler
@env.merge!({
'deas.params' => @params,
+ 'deas.splat' => @splat,
'deas.handler_class' => @handler_class
})
@middleware = Deas::SummaryLogging.new(@app)
end
@@ -235,10 +237,11 @@
summary_line = Deas::SummaryLine.new({
'method' => @env['REQUEST_METHOD'],
'path' => @env['PATH_INFO'],
'params' => @env['deas.params'],
+ 'splat' => @env['deas.splat'],
'time' => @env['deas.time_taken'],
'status' => @resp_status,
'handler' => @handler_class.name,
'redir' => @resp_headers['Location']
})
@@ -251,10 +254,11 @@
summary_line = Deas::SummaryLine.new({
'method' => @env['REQUEST_METHOD'],
'path' => @env['PATH_INFO'],
'params' => @env['deas.params'],
+ 'splat' => @env['deas.splat'],
'time' => @env['deas.time_taken'],
'status' => @resp_status,
'redir' => @resp_headers['Location']
})
assert_includes "[Deas] #{summary_line}", @logger.info_logged
@@ -266,10 +270,11 @@
summary_line = Deas::SummaryLine.new({
'method' => @env['REQUEST_METHOD'],
'path' => @env['PATH_INFO'],
'params' => @env['deas.params'],
+ 'splat' => @env['deas.splat'],
'time' => @env['deas.time_taken'],
'status' => @resp_status,
'handler' => @handler_class.name,
})
assert_includes "[Deas] #{summary_line}", @logger.info_logged
@@ -280,28 +285,30 @@
class SummaryLineTests < UnitTests
desc "Deas::SummaryLine"
subject{ Deas::SummaryLine }
should "output its attributes in a specific order" do
- assert_equal %w{time status method path handler params redir}, subject.keys
+ assert_equal %w{time status method path handler params splat redir}, subject.keys
end
should "output its attributes in a single line" do
line_attrs = {
'time' => 't',
'status' => 's',
'method' => 'm',
'path' => 'pth',
'handler' => 'h',
'params' => 'p',
+ 'splat' => 'spl',
'redir' => 'r'
}
exp_line = "time=\"t\" "\
"status=\"s\" "\
"method=\"m\" "\
"path=\"pth\" "\
"handler=\"h\" "\
"params=\"p\" "\
+ "splat=\"spl\" "\
"redir=\"r\""
assert_equal exp_line, subject.new(line_attrs)
end
should "only output keys if data exists for them" do