Skip to content

Rails 6.1.5 ignores net-smtp LoadError #44799

@JunichiIto

Description

@JunichiIto

Steps to reproduce

git clone git@github.com:JunichiIto/rails-6-1-mailer-sandbox.git
cd rails-6-1-mailer-sandbox
bin/setup
bin/rails test:system

Expected behavior

Fails to start server because of net-smtp LoadError

Actual behavior

Server can start up, then test fails with the error below:

2022-03-30 08:36:43 +0900 Rack app ("GET /" - (127.0.0.1)): #<NameError: uninitialized constant Mail::TestMailer

      delegate :deliveries, :deliveries=, to: Mail::TestMailer
                                                  ^^^^^^^^^^^^>
E

System configuration

Rails version:

  • 6.1.5

Ruby version:

  • 3.1.1

My investigation

The changes below were introduced since Rails 6.1.5:

However, the regexp should be /net\/stmp/ because error.message is "cannot load such file -- net/smtp":

Screen Shot 2022-03-30 at 8 04 32

Since net-smtp LoadError is ignored and mail gem is not loaded, the error "NameError: uninitialized constant Mail::TestMailer" is raised.

When I changed the regexp in my local box, the test fails like this:

You don't have net-smtp installed in your application. Please add it to your Gemfile and run bundle install
2022-03-30 08:47:59 +0900 Rack app ("GET /" - (127.0.0.1)): #<LoadError: cannot load such file -- net/smtp>
E

Error:
HomesTest#test_visiting_the_index:
LoadError: cannot load such file -- net/smtp
    app/mailers/application_mailer.rb:1:in `<main>'
    app/mailers/user_mailer.rb:1:in `<main>'
    app/controllers/home_controller.rb:3:in `index'


rails test test/system/homes_test.rb:4



Finished in 2.118014s, 0.4721 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips

I guess this is the expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions