lib/resqutils/spec/resque_matchers.rb in resqutils-1.1.1 vs lib/resqutils/spec/resque_matchers.rb in resqutils-1.2.0
- old
+ new
@@ -10,18 +10,30 @@
match do |queue_name|
jobs_matching(queue_name,expected_job_hash).first.size == 1
end
- failure_message_for_should do |queue_name|
+ failure_message_method = if defined?(failure_message)
+ :failure_message
+ else
+ :failure_message_for_should
+ end
+
+ send(failure_message_method) do |queue_name|
matching_jobs,all_jobs = jobs_matching(queue_name,expected_job_hash)
if matching_jobs.empty?
"No jobs in #{queue_name} matched #{expected_job_hash.inspect} (Found these jobs: #{all_jobs.map(&:inspect).join(',')})"
elsif matching_jobs.size > 1
"Mutiple jobs on #{queue_name} matched - try clearing queues before each test"
end
end
- failure_message_for_should_not do |queue_name|
+ failure_message_when_negated_method = if defined?(failure_message_when_negated)
+ :failure_message_when_negated
+ else
+ :failure_message_for_should_not
+ end
+
+ send(failure_message_when_negated_method) do |queue_name|
"Found job #{expected_job_hash.inspect} in the queue"
end
end