use active job test queue adapter in rspec

pull/105/head
Alex Turchyn 2 years ago
parent 601c984f3f
commit 52ba415429

@ -44,6 +44,7 @@ Rails.application.configure do
# The :test delivery method accumulates sent emails in the # The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
config.active_job.queue_adapter = :test
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr

@ -47,6 +47,7 @@ RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods config.include FactoryBot::Syntax::Methods
config.include Devise::Test::IntegrationHelpers config.include Devise::Test::IntegrationHelpers
config.include ActiveJob::TestHelper
config.before(:each, type: :system) do config.before(:each, type: :system) do
if ENV['HEADLESS'] == 'false' if ENV['HEADLESS'] == 'false'

@ -81,15 +81,7 @@ RSpec.describe 'Submit Form' do
expect do expect do
click_on 'Submit' click_on 'Submit'
end.to change { ActionMailer::Base.deliveries.size }.by(1) end.to change(enqueued_jobs, :size).by(3)
email = ActionMailer::Base.deliveries.last
expect(email.subject).to eq("#{submitter.email} has completed the \"#{template.name}\" form")
expect(email.body.encoded).to include "Hi #{user.first_name},"
expect(email.body.encoded).to include "#{submitter.email} has completed the \"#{template.name}\" form."
expect(email.body.encoded).to have_link('View Submission')
end end
end end
end end

Loading…
Cancel
Save