rspec-rails: uninitialized constant ActionMailer::DeliveryJob with latest rails/master
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.0.2 Rails version: 7.0.0 @ a0e14a8bfebf5f4bd4b66d1d468c844ab3e9d704 RSpec version: 5.0.2
Observed behaviour
6) Pitches::AcceptRequest#call updates pitch status
Failure/Error:
expect { call }.to change { User.count }.by(1)
.and change { BuyerProfile.count }.by(1)
.and change { pitch.reload.buyer_profile }.from(nil)
.and change { prospect.reload.invitation_accepted_at }.from(nil)
.and have_enqueued_email(PitchMailer, :request_accepted)
NameError:
uninitialized constant ActionMailer::DeliveryJob
Did you mean? ActionMailer::MailDeliveryJob
# ./spec/services/pitches/accept_request_spec.rb:36:in `block (3 levels) in <main>'
# -e:1:in `<main>'
Expected behaviour
Test was working before upgrading rails version
Can you provide an example app?
https://github.com/mhenrixon/rspec-rails-issue-2531 shows the error nicely
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (16 by maintainers)
Links to this issue
Commits related to this issue
- Fix removed ActionMailer::DeliveryJob in Rails 7 fixes #2531 Co-authored-by: Mikael Henriksson <mikael@mhenrixon.com> — committed to rspec/rspec-rails by pirj 3 years ago
- Add compatibility for have_enqueued_mail (rails 7) 1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been supers... — committed to mhenrixon/rspec-rails by mhenrixon 3 years ago
- Add compatibility for have_enqueued_mail (rails 7) 1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been supers... — committed to mhenrixon/rspec-rails by mhenrixon 3 years ago
- Add compatibility for have_enqueued_mail (rails 7) 1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been supers... — committed to mhenrixon/rspec-rails by mhenrixon 3 years ago
- Add compatibility for have_enqueued_mail (rails 7) 1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been supers... — committed to rspec/rspec-rails by mhenrixon 3 years ago
- Add compatibility for have_enqueued_mail (rails 7) 1. ActionMailer::DeliveryJob does not exist anymore 2. ActionMailer::Parameterized::DeliveryJob According to my research they have both been supers... — committed to rspec/rspec-rails by mhenrixon 3 years ago
- Upgrade rspec-rails to 6.0.0.rc1 To prevent possible issues with ActiveMailer: https://github.com/rspec/rspec-rails/issues/2531 — committed to abtion/rails-template by jeppester 2 years ago
- Upgrade rspec-rails to 6.0.0.rc1 To prevent possible issues with ActiveMailer: rspec/rspec-rails#2531 — committed to DFE-Digital/apply-for-qualified-teacher-status by thomasleese 2 years ago
Any chance of getting this in a tagged release soon?
This has been released as
6.0.0.rc1theres still potential for the breaking change to the mailer api to do with params / args matching, but those needing support from a tagged release can now get this via rc1.Rails 7 support is only via version 6.x per our versioning strategy.
I’m still getting the same error with
rspec-rails 5.1.1andrails 7.0.2.3edit: Sweet, I see someone else gave this a 👍 , I felt like maybe I had done something incredibly wrong, and everyone else was good to go 😄
Added this in
spec/supportand it seems to workWhat if you replace in https://github.com/rspec/rspec-rails/blob/d3e7b85877fcbcec63f8a76434d8750e7f3b7aef/lib/rspec/rails/matchers/have_enqueued_mail.rb#L134
will it fix your error?
The problem with
mainis that its version is 6.0.0-pre and other rspec libs (external) don’t yet support6.x. Will this only be available in a6.xrelease?@Petercopter The fix is in
main, but not in 5.1.1. I suggest usingmainuntil the fix is released on RubyGems.Thanks @pirj feel free to close this one if #2546 fixes the issue! I am still swamped with my attempt to make our new home livable. Just catching up on some notifications.
Added PR @pirj, please let me know if there is anything I should improve to get it merged.
Perfect, I’ll sort out a PR then! Thanks for following up
You won’t even have to write new specs for this code. Rails edge build already fails: