Skip to content

Interferes with Capybara tests even when only added to dev group #304

@mcmire

Description

@mcmire

Hey there -- it doesn't seem that this issue has been raised yet, and I don't even know if this issue is necessarily the fault of this gem, but I'm opening this in the hopes that I can get some pointers.

It seems that adding better_errors is interfering with Capybara feature tests, even when it's added only to the development group.

Here's what I did:

  • Made a simple vanilla Rails app (4.2.1)

  • Added rspec-rails (3.2.1)

  • Ran rails g rspec:install

  • Added the following to config/routes.rb: get /users, to: "users#index"

  • Added the following test to spec/features/my_feature_spec.rb

    require 'rails_helper'
    
    feature 'My feature' do
      scenario 'is awesome' do
        visit '/users'
        expect(page).to have_content('Users')
      end
    end
  • Ran the test. As expected, it fails with: ActionController::RoutingError: uninitialized constant UsersController

  • Then, I added better_errors to the Gemfile, but only in the development group

  • Ran the test again. Now it passes! How? Well, if you throw in a save_and_open_page then you'll get the text version of better_errors:

    ActionController::RoutingError at /users
    ========================================
    
    > uninitialized constant UsersController
    
    spec/features/my_feature_spec.rb, line 5
    ----------------------------------------
    
    ``` ruby
        1   require 'rails_helper'
        2   
        3   feature 'My feature' do
        4     scenario 'is awesome' do
    >   5       visit '/users'
        6       expect(page).to have_content('Users')
        7       save_and_open_page
        8     end
        9   end
    
    ... etc., etc. ...
    

    I realize this may be "expected" behavior, but my question is, why is this happening?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions