Skip to content
Browse files

Merge pull request #41 from xaviershay/fix-error-handling

Use default error handlers if none specified.
  • Loading branch information...
2 parents bcdb412 + 9c24436 commit 79b7cbbbc0e5c95cd6c3604266a9c7bce87528aa @mperham committed Nov 3, 2011
Showing with 15 additions and 1 deletion.
  1. +1 −1 lib/girl_friday/work_queue.rb
  2. +14 −0 test/test_girl_friday_queue.rb
View
2 lib/girl_friday/work_queue.rb
@@ -11,7 +11,7 @@ def initialize(name, options={}, &block)
@name = name.to_s
@size = options[:size] || 5
@processor = block
- @error_handlers = (Array(options[:error_handler]) || ErrorHandler.default).map(&:new)
+ @error_handlers = (Array(options[:error_handler] || ErrorHandler.default)).map(&:new)
@shutdown = false
@busy_workers = []
View
14 test/test_girl_friday_queue.rb
@@ -36,6 +36,20 @@ def test_should_handle_worker_error
end
end
+ def test_should_use_a_default_error_handler_when_none_specified
+ async_test do |cb|
+ queue = GirlFriday::WorkQueue.new('error') do |msg|
+ end
+ queue.shutdown do
+ cb.call
+ end
+ queue.push(:text => 'foo') # Redundant
+
+ # Not an ideal method, but I can't see a better way without complex stubbing.
+ assert queue.instance_eval { @error_handlers }.length > 0
+ end
+ end
+
def test_should_call_callback_when_complete
async_test do |cb|
queue = GirlFriday::WorkQueue.new('callback', :size => 1) do |msg|

0 comments on commit 79b7cbb

Please sign in to comment.
Something went wrong with that request. Please try again.