← Back to Upcase

Rspec NoMethodError: undefined method `visit'

(Grant Spilsbury) #1


I’ve just started the second app of the tdd workshop and I’m getting an unexpected rspec failure


  1) View the homepage learn about the application
     Failure/Error: visit root_path
       undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fc5e99c6a10>

Integration spec view_homepage_spec.rb

require 'spec_helper'

feature 'View the homepage' do
    scenario 'learn about the application' do
        visit root_path
        expect(page).to have_css 'title', text: 'Hashtag'
        expect(page).to have_css '[data-role= "description"]'

Here’s what’s in routes.rb

Hashtag::Application.routes.draw do
root to: 'high_voltage/pages#show', id: 'homepage'

And I have the highvoltage gem in the gemfile. I’ve also created app/views/pages/homepage.html.erb

Any help? Thanks

(Pedro Moreira) #2


Which version of Capybara are you using? If you aren’t explicitly setting it gem 'capybara', '1.1.4' in your Gemfile, you have to save your integration tests to spec/features/.

Also, make sure you delete public/index.html as well. That has tripped me one a few times while writing tests that involve the root path

(Grant Spilsbury) #3

Thank you! Set capybara to version 1.1.4 and it works.

(Pedro Moreira) #4

Sure, glad to help :slight_smile:

(Acandael Acandael) #5

Thanks pedromoreira,

I had the same issue as grantspilsbury,

locking Capybara to 1.1.4 solved the issue.



(Pedro Moreira) #6

Glad you got it working :slight_smile: