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.
You have to add config.include Capybara::DSL
to rails_helper.rb
, and not into spec_helper.rb
. It worked for me perfectly!
I think this could work. Try adding these lines in spec_helper.rb
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.include Capybara::DSL
end
Did you already run bundle install? Have you added
require 'capybara/rails'
in rails_helper.rb
If you are using Capybara you might want to follow the instructions here.
If you see this error in your specs, despite importing Capybara in spec_helper.rb
, adding .rspec
with the line --require spec_helper
to the root ought to fix the issue:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With