Rspec-rails: 3.7.0: LoadError: puma is now a dependency?

Created on 17 Oct 2017  Â·  14Comments  Â·  Source: rspec/rspec-rails

Hello friends. After updating from 3.6.1 to 3.7.0 I get a LoadError. It seems that rspec-rails now requires puma?

An error occurred while loading ./spec/views/users/edit_spec.rb.
Failure/Error: require 'rspec/rails'

LoadError:
  cannot load such file -- rack/handler/puma
# actionpack-5.1.4/lib/action_dispatch/system_testing/server.rb:1:in `<top (required)>'
# actionpack-5.1.4/lib/action_dispatch/system_test_case.rb:5:in `<top (required)>'
# rspec-rails-3.7.0/lib/rspec/rails/example/system_example_group.rb:2:in `<top (required)>'
# rspec-rails-3.7.0/lib/rspec/rails/example.rb:12:in `<top (required)>'
# rspec-rails-3.7.0/lib/rspec/rails.rb:13:in `<top (required)>'
# ./spec/rails_helper.rb:7:in `<top (required)>'
... etc

We still use WEBrick for our development and test environments.

bundle | grep puma | wc -l
       0

If puma is now a dependency of rspec-rails, let's add it to the gemspec.

Thanks!

Most helpful comment

what if someone is using thin or unicorn?

All 14 comments

This should only be the case on Rails 5.1+?

On 17 Oct 2017, at 17:13, Jared Beck notifications@github.com wrote:

Hello friends. After updating from 3.6.1 to 3.7.0 I get a LoadError. It seems that rspec-rails now requires puma?

An error occurred while loading ./spec/views/users/edit_spec.rb.
Failure/Error: require 'rspec/rails'

LoadError:
cannot load such file -- rack/handler/puma

actionpack-5.1.4/lib/action_dispatch/system_testing/server.rb:1:in `

actionpack-5.1.4/lib/action_dispatch/system_test_case.rb:5:in `

rspec-rails-3.7.0/lib/rspec/rails/example/system_example_group.rb:2:in `

rspec-rails-3.7.0/lib/rspec/rails/example.rb:12:in `

rspec-rails-3.7.0/lib/rspec/rails.rb:13:in `

./spec/rails_helper.rb:7:in `

... etc
We still use WEBrick for our development and test environments.

bundle | grep puma | wc -l
0
If puma is now a dependency of rspec-rails, let's add it to the gemspec.

Thanks!

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub https://github.com/rspec/rspec-rails/issues/1882, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF5lhsME5Xk4VUT3LmbbNqitPq-wt4Cks5stNIagaJpZM4P8Xz_.

Looking at this:

  • To use system test you must use puma
  • RSpec itself doesn’t bring in puma because we don’t necessarily encounter system tests in all apps
  • You should add puma to your Gemfile
  • We could make the error that you receive much better, as we do for other optional gems like capybara.

On 17 Oct 2017, at 17:13, Sam Phippen samphippen@googlemail.com wrote:

This should only be the case on Rails 5.1+?

On 17 Oct 2017, at 17:13, Jared Beck <[email protected] notifications@github.com> wrote:

Hello friends. After updating from 3.6.1 to 3.7.0 I get a LoadError. It seems that rspec-rails now requires puma?

An error occurred while loading ./spec/views/users/edit_spec.rb.
Failure/Error: require 'rspec/rails'

LoadError:
cannot load such file -- rack/handler/puma

actionpack-5.1.4/lib/action_dispatch/system_testing/server.rb:1:in `

actionpack-5.1.4/lib/action_dispatch/system_test_case.rb:5:in `

rspec-rails-3.7.0/lib/rspec/rails/example/system_example_group.rb:2:in `

rspec-rails-3.7.0/lib/rspec/rails/example.rb:12:in `

rspec-rails-3.7.0/lib/rspec/rails.rb:13:in `

./spec/rails_helper.rb:7:in `

... etc
We still use WEBrick for our development and test environments.

bundle | grep puma | wc -l
0
If puma is now a dependency of rspec-rails, let's add it to the gemspec.

Thanks!

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub https://github.com/rspec/rspec-rails/issues/1882, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF5lhsME5Xk4VUT3LmbbNqitPq-wt4Cks5stNIagaJpZM4P8Xz_.

Hi Sam, thanks for the quick response.

To use system test you must use puma

I don't think we have any system tests. I can reproduce the LoadError by running a single view spec, e.g. bin/rspec spec/views/users/edit_spec.rb. It is my understanding that view spec != system test, but maybe I'm missing something?

RSpec itself doesn’t bring in puma because we don’t necessarily encounter system tests in all apps

Based on the stack trace that I am able to reproduce, this statement seems to be incorrect?

  • lib/rspec/rails.rb:13 requires rspec/rails/example
  • rspec/rails/example.rb:12 requires rspec/rails/example/system_example_group
  • rspec/rails/example/system_example_group.rb:2 requires action_dispatch/system_test_case
  • actionpack-5.1.4/lib/action_dispatch/system_test_case.rb:5 requires action_dispatch/system_testing/server
  • action_dispatch/system_testing/server.rb:1 requires rack/handler/puma

whew! 😓

So, it seems that rspec-rails does indeed require puma (when ActionPack::VERSION::STRING >= "5.1"), but you'd know better, so what am I missing?

You should add puma to your Gemfile

If rspec-rails requires puma, shouldn't it be mentioned in the gemspec? I must be missing something here.

Thanks Sam.

I can also reproduce this error by running a model spec.

bin/rspec spec/models/user_spec.rb 

An error occurred while loading ./spec/models/user_spec.rb.
Failure/Error: require 'rspec/rails'

LoadError:
  cannot load such file -- rack/handler/puma
# ./spec/rails_helper.rb:7:in `<top (required)>'
# ./spec/models/user_spec.rb:3:in `require'
# ./spec/models/user_spec.rb:3:in `<top (required)>'

The detailed --backtrace is the same here as above, so, for brevity, I won't repeat it.

Open source example of failing specs because of missing puma https://circleci.com/gh/spree/spree/6466

RSpec itself doesn’t bring in puma because we don’t necessarily encounter system tests in all apps

This doesn't seem to be the case. For any Rails 5.1+ app, puma will be required, regardless of if system tests are used.

This shouldn’t be too hard to fix . We can require puma before we define the type and rescue if we get a load error. I’ll try to do a bug fix release soon!

Sent from my phone please excuse my brevity.

On 17 Oct 2017, at 21:15, John Hawthorn notifications@github.com wrote:

RSpec itself doesn’t bring in puma because we don’t necessarily encounter system tests in all apps

This doesn't seem to be the case, for any Rails 5.1+ app, puma will be required, regardless of if system tests are used.

example.rb will require system_example_group
system_example_group.rb will require action_dispatch/system_test_case
system_test_case.rb will require system_testing/server
system_testing/server.rb will require rack/handler/puma
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

System tests only work with puma and we didn’t quite guard against puma not being present in the right way. If you don’t want to use puma and system tests, this is something that will work once I’ve rolled out a fix

Sent from my phone please excuse my brevity.

On 17 Oct 2017, at 21:15, John Hawthorn notifications@github.com wrote:

RSpec itself doesn’t bring in puma because we don’t necessarily encounter system tests in all apps

This doesn't seem to be the case, for any Rails 5.1+ app, puma will be required, regardless of if system tests are used.

example.rb will require system_example_group
system_example_group.rb will require action_dispatch/system_test_case
system_test_case.rb will require system_testing/server
system_testing/server.rb will require rack/handler/puma
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

https://github.com/rspec/rspec-rails/pull/1884/ in the mean time you can point your apps at this pull request to fix this issue.

@samphippen I think it's way better to just lock rspec-rails version on 3.6.1...

what if someone is using thin or unicorn?

This has been fixed with the release of RSpec 3.7.1

This has been fixed with the release of RSpec 3.7.1

Works for me, thanks Sam.

Could someone who encountered the original issue test #1893, it fixes a regression this caused in some cases and I'd like to test it still fixes this issue to.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulwalker picture paulwalker  Â·  5Comments

Matrixbirds picture Matrixbirds  Â·  4Comments

dwightwatson picture dwightwatson  Â·  3Comments

bibisreebi picture bibisreebi  Â·  5Comments

benpickles picture benpickles  Â·  5Comments