aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-20 11:45:29 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-20 11:57:07 -0800
commitd42b3d4347547b7790d0a716e7548baccf408076 (patch)
treeb899316957a7593d86bae2847bebf75e0f87154a /activesupport/test
parent30b0e5848c5a91c0bfd1ef33ec4b9bc36bcead0b (diff)
downloadrails-d42b3d4347547b7790d0a716e7548baccf408076.tar.gz
rails-d42b3d4347547b7790d0a716e7548baccf408076.tar.bz2
rails-d42b3d4347547b7790d0a716e7548baccf408076.zip
add a broadcasting logger so we can split logs
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/broadcast_logger_test.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/activesupport/test/broadcast_logger_test.rb b/activesupport/test/broadcast_logger_test.rb
new file mode 100644
index 0000000000..af34221cfe
--- /dev/null
+++ b/activesupport/test/broadcast_logger_test.rb
@@ -0,0 +1,57 @@
+require 'abstract_unit'
+
+module ActiveSupport
+ class BroadcastLoggerTest < TestCase
+ def test_debug
+ log1 = FakeLogger.new
+ log2 = FakeLogger.new
+
+ logger = BroadcastLogger.new [log1, log2]
+ logger.debug "foo"
+ assert_equal 'foo', log1.adds.first[2]
+ assert_equal 'foo', log2.adds.first[2]
+ end
+
+ def test_close
+ log1 = FakeLogger.new
+ log2 = FakeLogger.new
+
+ logger = BroadcastLogger.new [log1, log2]
+ logger.close
+ assert log1.closed, 'should be closed'
+ assert log2.closed, 'should be closed'
+ end
+
+ def test_chevrons
+ log1 = FakeLogger.new
+ log2 = FakeLogger.new
+
+ logger = BroadcastLogger.new [log1, log2]
+ logger << "foo"
+ assert_equal %w{ foo }, log1.chevrons
+ assert_equal %w{ foo }, log2.chevrons
+ end
+
+ class FakeLogger
+ attr_reader :adds, :closed, :chevrons
+
+ def initialize
+ @adds = []
+ @closed = false
+ @chevrons = []
+ end
+
+ def << x
+ @chevrons << x
+ end
+
+ def add(*args)
+ @adds << args
+ end
+
+ def close
+ @closed = true
+ end
+ end
+ end
+end