class ActiveJob::QueueAdapters::TestAdapter
Test adapter for Active Job¶ ↑
The test adapter should be used only in testing. Along with
ActiveJob::TestCase
and ActiveJob::TestHelper
it
makes a great tool to test your Rails
application.
To use the test adapter set queue_adapter config to :test
.
Rails.application.config.active_job.queue_adapter = :test
Attributes
enqueued_jobs[W]
filter[RW]
perform_enqueued_at_jobs[RW]
perform_enqueued_jobs[RW]
performed_jobs[W]
Public Instance Methods
enqueued_jobs()
click to toggle source
Provides a store of all the enqueued jobs with the TestAdapter so you can check them.
# File lib/active_job/queue_adapters/test_adapter.rb, line 17 def enqueued_jobs @enqueued_jobs ||= [] end
performed_jobs()
click to toggle source
Provides a store of all the performed jobs with the TestAdapter so you can check them.
# File lib/active_job/queue_adapters/test_adapter.rb, line 22 def performed_jobs @performed_jobs ||= [] end
Private Instance Methods
enqueue_or_perform(perform, job, job_data)
click to toggle source
# File lib/active_job/queue_adapters/test_adapter.rb, line 45 def enqueue_or_perform(perform, job, job_data) if perform performed_jobs << job_data Base.execute job.serialize else enqueued_jobs << job_data end end
filtered?(job)
click to toggle source
# File lib/active_job/queue_adapters/test_adapter.rb, line 54 def filtered?(job) filter && !Array(filter).include?(job.class) end
job_to_hash(job, extras = {})
click to toggle source
# File lib/active_job/queue_adapters/test_adapter.rb, line 41 def job_to_hash(job, extras = {}) { job: job.class, args: job.serialize.fetch("arguments"), queue: job.queue_name }.merge!(extras) end