mperham/sidekiq — pull request #963 by fumin (2013-05-30 06:07:00+00:00)
Title: Add a testing method shift_and_perform to dequeue a single job

We ran into a case where in our tests, we'd need to dequeue only a single job and run it. Since `drain` dequeues all jobs, we couldn't use it.

In particular, our case consists of a worker that spawns another worker if needed
```
class SomeWorker
include Sidekiq::Worker

def perform items
items_that_need_retry = M.do_work items
SomeWorker.perform_async( items_that_need_retry )
end
```

To test this worker, we'd need to a way to dequeue only one job with `shift_and_perform`.
```
class Test

test 'retry' do
SomeWorker.perform_async [1,2]

mock(M).do_work([1,2]){ [1] }
assert_no_difference 'SomeWorker.jobs.size' do
SomeWorker.shift_and_perform
end

mock(M).do_work([1]){ [] }
SomeWorker.shift_and_perform
assert_equal 0, SomeWorker.jobs.size
end

end
```