Skip to content

Commit daf785d

Browse files
committed
Update test runner to use the queue
This is the setup required for using ActiveJob and its queue, and checking if things were enqueued. Signed-off-by: jonathan.kerr <3410350+jonodrew@users.noreply.github.com>
1 parent fabb71e commit daf785d

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

config/environments/test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "active_support/core_ext/integer/time"
22
require "timecop"
3+
require "active_job/test_helper"
34

45
# The test environment is used exclusively to run your application's
56
# test suite. You never need to work with it otherwise. Remember that
@@ -55,6 +56,8 @@
5556
# Raise error when a before_action's only/except options reference missing actions.
5657
config.action_controller.raise_on_missing_callback_actions = true
5758

59+
config.active_job.queue_adapter = :test
60+
5861
# Fake omniauth for testing
5962
OmniAuth.config.test_mode = true
6063

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def self.branch_coverage?
5757
ActiveRecord::Migration.check_all_pending! if defined?(ActiveRecord::Migration)
5858

5959
RSpec.configure do |config|
60+
config.include ActiveJob::TestHelper
6061
config.include ApplicationHelper
6162
config.include LoginHelpers
6263
config.include ActiveSupport::Testing::TimeHelpers
@@ -95,6 +96,9 @@ def self.branch_coverage?
9596
to_return(status: 200, body: '{"status":"active","segments":[]}', headers: { 'Content-Type' => 'application/json' })
9697

9798
DatabaseCleaner.strategy = :transaction
99+
100+
clear_enqueued_jobs
101+
clear_performed_jobs
98102
end
99103

100104
# Driver is using an external browser with an app

0 commit comments

Comments
 (0)