rspec/rspec-rails

Rails 7.1 upgrade: using deprecated preview_path=

juanxcerv opened this issue ยท 9 comments

What Ruby, Rails and RSpec versions are you using?

Ruby version: 3.2.2
Rails version: 7.1.1
RSpec version: 3.12

Observed behaviour

Inside of rspec-rails-6.0.3/lib/rspec-rails.rb it's using the deprecated method preview_path:

 options.preview_path = "#{::Rails.root}/spec/mailers/previews"

which ultimately gets set as a config for action_mailer:

      initializer "rspec_rails.action_mailer",
                  before: "action_mailer.set_configs" do |app|
                    setup_preview_path(app)
                  end

and causes the following message to trigger:

        ActionMailer.deprecator.warn(<<-MSG.squish)
          Using preview_path= option is deprecated and will be removed in Rails 7.2.
          Please use preview_paths= instead.
        MSG

Expected behaviour

No deprecation warning

Thanks!

pirj commented

Thanks for the in-depth report, Do you want to send a PR to fix this, @juanxcerv ?

This can be reproduced with this clean ruby 7.1.1 project: https://github.com/dannyy83/debug_action_mailer_deprication

You can see the deprication warning being raised by visiting the /rails/mailers/ url.

@JonRowe Thank you for fixing!! Would you be able to cut a new release ๐Ÿ™๐Ÿผ

Hit this during an upgrade to Ruby 3.3.5 / Rails 7.2.x. Running on master resolved that exception around preview_path=.

Thats funny we don't have a master branch, prehaps you meant main but also this was released in 6.1.0 in 2023, we're on 7.0.x now which also has that fix.

My apologies. Main. I was still experiencing this in rspec-rails 7.0. May have been a cache issue, but had to switch to the github call in the gemfile.

hit this on upgrade from 6.x to 3.3.5/7.2.1 and 3.3.5/8.0.0.beta1, removed cache/reinstated gem set, still an issue.
undefined method preview_path=' for class ActionMailer::Base`
Any idea how to solve it?

hit this on upgrade from 6.x to 3.3.5/7.2.1 and 3.3.5/8.0.0.beta1, removed cache/reinstated gem set, still an issue. undefined method preview_path=' for class ActionMailer::Base` Any idea how to solve it?

@alexthe777 I found that I had rspec-rails 6.x still locked in, even though the gemfile did not specify a number (this was an older app). I did gem uninstall on all rspec, set the line to reflect the main branch ( gem "rspec-rails", github: "rspec/rspec-rails", branch: "main") and ran bundle update and was good to go.

@jathayde worked like magic, thank you so much!