I cannot get capybara to work. I am using capybara 2.0.0
I get this error
Failure/Error: visit \"/users/sign_in\"
NoMethodError:
undefine
In my case, I got this error because I forgot to putrequire "spec_helper"
at the top of my new spec file.
I've done it enough times that I'm adding an answer to an already answered question in hopes that it helps some other knucklehead (or most likely me searching this again in the future).
If you've got version >= 2.0
, any tests that use Capybara methods like visit
should go under a spec/features directory, and not under spec/requests, where they'd normally reside in Capybara 1.1.2
.
Have a look at the following links for more information:
If you don't want to use a spec/features directory, you should be able to mark a test as a feature
in the following way and have Capybara methods work:
describe "Some action", type: :feature do
before do
visit "/users/sign_in"
# ...
end
# ...
end