diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-04-30 15:00:15 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-04-30 15:00:15 -0500 |
commit | d327496ab7499d7000f4a6c57173219a8738bed0 (patch) | |
tree | bd93b977bc6971f5859fc9120279803688a8a66b | |
parent | 56861af7339559dd66a9cf38150fc2a2d0c9931c (diff) | |
download | rails-d327496ab7499d7000f4a6c57173219a8738bed0.tar.gz rails-d327496ab7499d7000f4a6c57173219a8738bed0.tar.bz2 rails-d327496ab7499d7000f4a6c57173219a8738bed0.zip |
Fixed tests (and the weird assumption that no logger would mean that the code wasnt run)
-rw-r--r-- | actionpack/lib/action_view/helpers/benchmark_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/benchmark_helper_test.rb | 26 |
2 files changed, 8 insertions, 20 deletions
diff --git a/actionpack/lib/action_view/helpers/benchmark_helper.rb b/actionpack/lib/action_view/helpers/benchmark_helper.rb index c278a38f25..743d1d40ec 100644 --- a/actionpack/lib/action_view/helpers/benchmark_helper.rb +++ b/actionpack/lib/action_view/helpers/benchmark_helper.rb @@ -23,7 +23,7 @@ module ActionView def benchmark(message = "Benchmarking", level = :info) if controller.logger real = Benchmark.realtime { yield } - controller.logger.send level, "#{message} (#{'%.5f' % real})" + controller.logger.send(level, "#{message} (#{'%.5f' % real})") else yield end diff --git a/actionpack/test/template/benchmark_helper_test.rb b/actionpack/test/template/benchmark_helper_test.rb index d95a3dee26..08d453c965 100644 --- a/actionpack/test/template/benchmark_helper_test.rb +++ b/actionpack/test/template/benchmark_helper_test.rb @@ -16,32 +16,20 @@ class BenchmarkHelperTest < ActionView::TestCase end end - def setup - @logger = MockLogger.new - end - - def test_without_logger_or_block - @logger = nil - assert_nothing_raised { benchmark } + def controller + @controller ||= Struct.new(:logger).new(MockLogger.new) end def test_without_block assert_raise(LocalJumpError) { benchmark } - assert @logger.logged.empty? - end - - def test_without_logger - @logger = nil - i_was_run = false - benchmark { i_was_run = true } - assert !i_was_run + assert controller.logger.logged.empty? end def test_defaults i_was_run = false benchmark { i_was_run = true } assert i_was_run - assert 1, @logger.logged.size + assert 1, controller.logger.logged.size assert_last_logged end @@ -49,7 +37,7 @@ class BenchmarkHelperTest < ActionView::TestCase i_was_run = false benchmark('test_run') { i_was_run = true } assert i_was_run - assert 1, @logger.logged.size + assert 1, controller.logger.logged.size assert_last_logged 'test_run' end @@ -57,13 +45,13 @@ class BenchmarkHelperTest < ActionView::TestCase i_was_run = false benchmark('debug_run', :debug) { i_was_run = true } assert i_was_run - assert 1, @logger.logged.size + assert 1, controller.logger.logged.size assert_last_logged 'debug_run', :debug end private def assert_last_logged(message = 'Benchmarking', level = :info) - last = @logger.logged.last + last = controller.logger.logged.last assert 2, last.size assert_equal level, last.first assert 1, last[1].size |