1

Just trying to get through the last bit of chapter 5 in Michael Hartl's Ruby on Rails Tutorial and getting another error running RSpec tests.

The output is :

Static pages should have the right links on the layout Failure/Error: expect(page).to have_title('About Us') NoMethodError: undefined method has_title?' for #<Capybara::Session> # ./spec/requests/static_pages_spec.rb:59:inblock (2 levels) in '

and results from the line starting expect(page) in the following code in static_pages_spec.rb :

it "should have the right links on the layout" do
    visit root_path
    click_link "About"
   expect(page).to have_title(full_title('About Us'))
end   

Note : This happens running with or without Spork

Can anyone point me in the right direction please ?

Thanks, Bazza

Bazza Formez
  • 179
  • 5
  • 16

1 Answers1

7

The have_title function is supported from Capybara 2.1. I suppose you have an older version of Capybara in your Gemfile. So, update your Gemfile with

gem 'capybara', '2.1.0'

then update Capybara like this

bundle update capybara

and rerun the specs using rspec. It should work now

Refer to this post for other options

Community
  • 1
  • 1
quirkystack
  • 1,387
  • 2
  • 17
  • 42