I am trying to test the title of my static pages in rails. I'm using Capybara 2.4.4 and rspec 3.
My test looks like the following static_pages_controller_spec.rb
require 'spec_helper'
require 'rails_helper'
describe StaticPagesController do
describe "GET 'Index'" do
it "should be successful" do
visit root_path
response.should be_success
end
it "should have the right title" do
visit root_path
expect(page).to have_selector('title',
:text => "Index",
:visible => false)
end
end
end
The page does have the correct title set. The error I'm getting says the following
Failure/Error: expect(page).to have_selector('title',
expected to find css "title" with text "Index" but there were no matches