Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

Commit

Permalink
Added Qe.drain for testing execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Aug 5, 2013
1 parent da15fa4 commit 8cdc123
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/qe/testing.rb
Expand Up @@ -3,6 +3,12 @@ def self.jobs
@jobs ||= []
end

def self.drain
jobs.each do |job|
Qe::Worker.perform(job[:worker].name, job[:options])
end
end

class Testing
def self.enqueue(worker, options = {})
Qe.jobs << {worker: worker, options: options}
Expand Down
14 changes: 14 additions & 0 deletions spec/qe/testing_spec.rb
Expand Up @@ -18,4 +18,18 @@

expect(job).to include(run_at: date)
end

it "runs jobs" do
Qe::Testing.enqueue(HelloWorker, a: 1)

instance = double.as_null_object
instance.should_receive(:perform)

HelloWorker
.should_receive(:new)
.with(a: 1)
.and_return(instance)

Qe.drain
end
end

0 comments on commit 8cdc123

Please sign in to comment.