Ok so I'm kinda new, but have somewhat of an idea of what I'm doing, but this one just has me stumped for the past couple hours, so any help is very much appreciated. I'm building a site and have been using Rspec and Capybara to test my site as I'm moving along. I ended up needing to remove turbolinks to improve functionality for my jscripts. The next time I try to run tests, literally 50% of my test suite just magically broke. I've narrowed it down to that the commonality between all the failures was that the "visit" either appeared in or just before the code block. So basically removing Turbolinks somehow blew Capybara up or Rspec. I'm really having some trouble figuring this one out. I tried updating the gems, that didn't work. I guess the next step is either skip the TDD concept, which I don't want to do, or start uninstalling the gems and do a reinstall and pray that that doesn't render my app useless... Any help anyone can provide is much appreciated, and if you're in NYC I'll buy you a beer.
There are also other tests that are failing that don't require any sort of authentication, just to check the page for title and content and those are failing to. I bring that up only to say I don't think that FactoryGirl is causing the problem.
Cheers.
The errors
2) User pages profile page
Failure/Error: before { visit user_path(user) }
NoMethodError:
undefined method `user_path' for #<RSpec::ExampleGroups::UserPages::ProfilePage:0x00000004290410>
# ./spec/requests/user_pages_spec.rb:10:in `block (3 levels) in <top (required)>'
3) User pages profile page
Failure/Error: before { visit user_path(user) }
NoMethodError:
undefined method `user_path' for #<RSpec::ExampleGroups::UserPages::ProfilePage:0x00000004207c00>
# ./spec/requests/user_pages_spec.rb:10:in `block (3 levels) in <top (required)>'
4) User pages signup page
Failure/Error: before { visit signup_path }
NameError:
undefined local variable or method `signup_path' for #<RSpec::ExampleGroups::UserPages::SignupPage:0x000000041b3088>
# ./spec/requests/user_pages_spec.rb:18:in `block (3 levels) in <top (required)>'
The test suite code
require 'spec_helper'
describe "User pages" do
subject { page }
#Profile tests
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_content(user.name) }
it { should have_title(user.name) }
end
#Signup page tests
describe "signup page" do
before { visit signup_path }
it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
describe "signup" do
before { visit signup_path }
let(:submit) { "Create my account" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
end
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "[email protected]"
fill_in "Password", with: "foobar00"
fill_in "Confirmation", with: "foobar00"
end
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
end
end
end