Permalink
Browse files

Allow specification of a custom queue class

  • Loading branch information...
1 parent 64c9cac commit 664f96ace0b371685fa3d919cf9ac33705a5013e @alindeman alindeman committed Oct 17, 2011
Showing with 11 additions and 2 deletions.
  1. +2 −2 lib/extras/queued_log_message_handler.rb
  2. +9 −0 spec/lib/extras/queued_log_message_handler_spec.rb
View
4 lib/extras/queued_log_message_handler.rb
@@ -9,10 +9,10 @@ class QueuedLogMessageHandler < BaseHandler
# later.
attr_accessor :message_limit
- def initialize(name)
+ def initialize(name, opts = {})
super(name)
- @queue = Queue.new
+ @queue = opts[:queue] || Queue.new
end
def Log(messages)
View
9 spec/lib/extras/queued_log_message_handler_spec.rb
@@ -44,4 +44,13 @@
subject.queue.size.should eq(1)
end
end
+
+ context "with a custom queue" do
+ let(:queue) { Queue.new }
+ subject { described_class.new("Test Handler", :queue => queue) }
+
+ it "accepts a custom queue object" do
+ subject.queue.should equal(queue)
+ end
+ end
end

0 comments on commit 664f96a

Please sign in to comment.