diff --git a/README.md b/README.md index 509bac1..d8ef18d 100644 --- a/README.md +++ b/README.md @@ -476,6 +476,7 @@ Contributors * Ilya Katz (@ilyakatz) : Cleanup README.md for RSpec 3 * (@addbrick) : Compare times as integers in `have_scheduled` matcher * Serious Haircut (@serioushaircut) : Fix ArgumentListMatcher to make it work with any\_args +* Peter Boling (@pboling) : Fix `queue` to return jobs of Worker class specified to correct `size` Copyright ========= diff --git a/lib/resque_spec/matchers.rb b/lib/resque_spec/matchers.rb index b675dc7..beba433 100644 --- a/lib/resque_spec/matchers.rb +++ b/lib/resque_spec/matchers.rb @@ -27,9 +27,18 @@ def in(queue_name) def queue(actual) if @queue_name + # All the Jobs in a queue ResqueSpec.queue_by_name(@queue_name) else - ResqueSpec.queue_for(actual) + # Only the Jobs for the given class (actual) in a queue. + # Why? A single queue can be used by multiple workers. + ResqueSpec.queue_for(actual).select do |queued| + if actual.respond_to?(:name) + queued[:class] == actual.name + else + queued[:class].to_s == actual.to_s + end + end end end end