In a Rails 3 application using Steak, Capybara and RSpec how do I test the page\'s title?
You should be able to search for the title
element to make sure it contains the text you want:
page.should have_xpath("//title", :text => "My Title")
Testing the Title of each page can be done in a much easier way with RSpec.
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
before(:each) do
get 'home'
@base_title = "Ruby on Rails"
end
it "should have the correct title " do
response.should have_selector("title",
:content => @base_title + " | Home")
end
end
end