rspec-rails: Wrong error message when System Tests cannot run
I struggled quite long with this error message:
System test integration requires Rails >= 5.1 and has a hard dependency on a webserver and
capybara, please add capybara to your Gemfile and configure a webserver (e.g.Capybara.server = :webrick) before attempting to use system tests.
which is very detailed but was actually pointing me in the wrong direction. After manually checking what was going on here I found out that the original exception was the following:
irb(main):002:0> require 'action_dispatch/system_test_case'
LoadError: cannot load such file -- rack/handler/puma
and therefore the fact that I did not have puma in by test group of Gemfile.
I would suggest to not suppress the original error and print also the original stacktrace to give proper information about what is going on. If you agree I’ll open a PR.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 16 (13 by maintainers)
Commits related to this issue
- Upgrades: update gems In preparation for the Rails 5.2 upgrade, I want our dependencies to be as fresh as possible. I locked down Capybara, though, due to a strange error about missing a server. This... — committed to helios-coop/corner by mockdeep 6 years ago
- Upgrades: update gems (#146) In preparation for the Rails 5.2 upgrade, I want our dependencies to be as fresh as possible. I locked down Capybara, though, due to a strange error about missing a ser... — committed to helios-coop/corner by mockdeep 6 years ago
It would be nice if the original error message was re-raised. The error in my case that was swallowed is:
Rspec’s suggestion to install capybara is misleading because I do have
in my Gemfile, it’s just that capybara’s recent release of version 3.0 conflicts with Rails’s runtime requirement of ~> 2.13.
It looks like Rails has since loosened the requirement, but people will still run into this on certain released versions of Rails.
@abevoelker I have the same issue as you did. Were you able to upgrade to capybara to v3 while remaining on Rails 5.1.x? Or you remained on capybara v2 for now?
The original error is printed now via #1959
@JonRowe my suggestion on how to improve the message is to also print the original exception. I wrote that in the first comment; if you think that could be useful I’ll open a PR. Due to the amount of messages in this thread seems like something that could save some pain/time to people.
The problem is the stack trace is misleading in the majority of cases, as the problem is improper configuration, in your case it looks like you hadn’t added Capybara to the Gemfile as the message warns about.
Thinking about it I think I’d support adding a message about trying to
require 'action_dispatch/system_test_case'manually to diagnose the issue.