uninitialized constant Capybara (NameError) in rails app

desbest picture desbest · Oct 17, 2013 · Viewed 11.6k times · Source

c:/mowes/www/rails_projects/sample_app/spec/spec_helper.rb:4:in `block in ': uninitialized constant Capybara (NameError)

spec/spec_helper.rb

# This file is copied to spec/ when you run 'rails generate rspec:install'

RSpec.configure do |config|
  config.include Capybara::DSL
end

I have gem 'capybara', '2.1.0' in my Gemfile so I don't know what's going on.

Answer

Liuda picture Liuda · Aug 10, 2014

You have to add config.include Capybara::DSL to rails_helper.rb, and not into spec_helper.rb. It worked for me perfectly!