I have a problem testing on rails with Capybara. Whenever I run it, it tells me that I have an “uninitialized Capybara constant (NameError)” in my spec_helper.rb file.
I follow this guide:
http://www.railstutorial.org/book/static_pages#code-capybara_dsl
This is my spec_helper.rb
RSpec.configure do |config|
config.include(Capybara::DSL)
end
and I'm trying to run this test static_pages_spec.rb
require 'spec_helper'
describe "Static pages" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
If there is any other additional information, just let me know.
-------- UPDATE ----------------
I understood the problem. Rspec version I create the rails_helper.rb file in the spec folder. I had to do:
require 'capybara/rspec'
in this file and config.include Capybara :: DSL in configurations.
----- ------------
: , "" - undefined.
undefined method `visit' for #<RSpec::ExampleGroups::StaticPages::AboutPage:0x000001033f5d50>
"capybara" "capybara/dsl", , .