diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-25 16:48:50 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-25 16:48:50 +0000 |
commit | 106b236824bbdf1cc9675b9531bac0c30a1926b0 (patch) | |
tree | 227b78f7cc265d0e51ee6158b032f5ffd81f2e96 | |
parent | 6f0390c957d77d74ace3258fbeac5ae8a9a0b7b8 (diff) | |
download | rails-106b236824bbdf1cc9675b9531bac0c30a1926b0.tar.gz rails-106b236824bbdf1cc9675b9531bac0c30a1926b0.tar.bz2 rails-106b236824bbdf1cc9675b9531bac0c30a1926b0.zip |
Include the tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7635 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activesupport/test/buffered_logger_test.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/activesupport/test/buffered_logger_test.rb b/activesupport/test/buffered_logger_test.rb new file mode 100644 index 0000000000..7d55715084 --- /dev/null +++ b/activesupport/test/buffered_logger_test.rb @@ -0,0 +1,41 @@ +require File.dirname(__FILE__) + '/abstract_unit' +require 'stringio' + +class BufferedLoggerTest < Test::Unit::TestCase + def setup + @message = "A debug message" + @output = StringIO.new + @logger = ActiveSupport::BufferedLogger.new(@output) + end + + def test_should_log_debugging_message_when_debugging + @logger.level = Logger::DEBUG + @logger.add(Logger::DEBUG, @message) + assert @output.string.include?(@message) + end + + def test_should_not_log_debug_messages_when_log_level_is_info + @logger.level = Logger::INFO + @logger.add(Logger::DEBUG, @message) + assert ! @output.string.include?(@message) + end + + def test_should_add_message_passed_as_block_when_using_add + @logger.level = Logger::INFO + @logger.add(Logger::INFO) {@message} + assert @output.string.include?(@message) + end + + def test_should_add_message_passed_as_block_when_using_shortcut + @logger.level = Logger::INFO + @logger.info {@message} + assert @output.string.include?(@message) + end + + def test_should_not_evaluate_block_if_message_wont_be_logged + @logger.level = Logger::INFO + evaluated = false + @logger.add(Logger::DEBUG) {evaluated = true} + assert evaluated == false + end +end |