Closed adamalbrecht closed 1 year ago
For anyone that happens to pop in here, I sort of monkey-patched for my case.
# spec/support/mosquito_helper.cr
module Mosquito
abstract class QueuedJob < Job
ENQUEUED_JOBS = [] of String
def enqueue
ENQUEUED_JOBS << self.class.name
end
end
end
# spec/your_thing_spec.cr
describe "Sending jobs" do
before_each do
Mosquito::QueuedJob::ENQUEUED_JOBS.clear
end
it "sends a job" do
MyCode.run
Mosquito::QueuedJob::ENQUEUED_JOBS.should contain("MyJob")
end
end
but yes, an official way would be awesome.
@adamalbrecht @jwoertink if you're still interested, please have a look at #117. Thank you!
It would be nice if there were some sort of test mode where I can either just assert that a job was added to the queue or run the jobs immediately when queued.
Here is some information on how this is done in Sidekiq (for ruby): https://github.com/mperham/sidekiq/wiki/Testing
Thanks!