I'm having a problem running a test in rails with Capybara. Whenever I run it, it tells me I have an 'uninitialized constant Capybara (NameError)' in my spec_helper.rb file.
I'm following this tutorial: 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 more information needed just let me know
--------UPDATE----------------
I figured out the problem. The version of Rspec I have creates a rails_helper.rb file in the spec folder. I had to do:
require 'capybara/rspec'
in that file and config.include Capybara::DSL in the configurations.
-----New Problem------------ But now I get another problem it is saying that 'visit' is undefined.
undefined method `visit' for #<RSpec::ExampleGroups::StaticPages::AboutPage:0x000001033f5d50>
I tried require 'capybara', and require 'capybara/dsl' but they all still give me errors and then some.
require 'capybara/rspec'
? This - github.com/jnicklas/capybara#using-capybara-with-rspec – Arup Rakshit