I’ve been following along with Michael Hartl’s tutorial, although for some reason I seem to be getting this error when testing:
Failures:
1) PagesController GET 'home' should have the right title
Failure/Error: response.should have_selector("title",
expected css "title" to return something
# ./spec/controllers/pages_controller_spec.rb:18:in `block (3 levels) in <top (required)>'
Finished in 0.11535 seconds
4 examples, 1 failure
Failed examples:
rspec ./spec/controllers/pages_controller_spec.rb:16 # PagesController GET 'home' should have the right title
Randomized with seed 19403
Here are my pages_controller_spec file contents:
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
it "returns http success" do
get 'home'
response.should be_success
end
it "should have the right title" do
get 'home'
response.should have_selector("title",
:content => "Ruby on rails tutorial sample app | Home")
end
end
describe "GET 'contact'" do
it "returns http success" do
get 'contact'
response.should be_success
end
end
describe "GET 'about'" do
it "returns http success" do
get 'about'
response.should be_success
end
end
end
And here are the contents of my home.html.erb file:
<!DOCTYPE>
<html>
<head>
<title>Ruby on rails tutorial sample app | Home</title>
</head>
<body>
<h1>Pages#home</h1>
<p>Find me in app/views/pages/home.html.erb</p>
</body>
</html>
Yeah that happened to me too. Please just make sure that you are using that exact version of Capybara mentioned in the tutorial. i.e. 1.1.2
I have tried many variations and alternatives and have reached the conclusion that there is still some compatibility issues in the latest Capybara.
Hope this helps.
My advice is to push on with the tutorial. In just a few steps, you will be pass the tests.