This seems to be a common issue, but I've looked at undefined method `visit' when using RSpec and Capybara in rails and Rails Rspec error - undefined method `visit' and neither solution works for me.
Capybara is working just fine for the Cucumber tests I have under /features.
My RSpec test is in /spec/features and begins:
require 'rails_helper'
describe 'session_project', type: :controller do
before(:each) do
@user = User.create(
username: 'user',
password: 'test',
password_confirmation: 'test',
email: 'user@example.com',
role: 3
)
@project = Project.create(name: 'Project 1', active: true, user_id: @user.id)
end
context 'when I am on the view Project 1 page' do
before do
visit '/projects'
find(:xpath, %{//tr[td='Project 1']/td[@class='list_actions']/a[text()='View']}).click
end
# ... and so on.
The line visit '/projects'
is giving me the error Undefined method 'visit
If I include config.include Capybara::DSL
in my RSpec configuration it complains that Capybara
is an undefined constant, so perhaps RSpec is looking in the wrong place for it?
Any ideas on how I can get RSpec working with Capybara?