2013-04-18 43 views
1

我有测试have_selector测试页面标题不工作

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 

以下代码但是当我运行rspec的投机/我有错误验证页面标题。我已经修改了home.html.erb这个

<!DOCTYPE html> 
<html> 
<head> 
    <title>Ruby on Rails Tutorial Sample App | Home</title> 

</head> 
<body> 
    <h1>Sample App Home Page</h1> 
    <p>Find me in app/views/pages/home.html.erb</p> 
</body> 
</html> 

我有 rspec的版本2.13.0 水豚版本2.1.0

+0

的可能的复制[验证页面标题与rspec](http://stackoverflow.com/questions/3971449/verifying-page-title-with-rspec) – 2016-02-13 13:35:05

回答

0

尝试:

response.should have_content "Ruby on Rails Tutorial Sample App | Home" 
+0

我仍然有以下错误: < - [31mrspec ./spec/controllers /pages_controller_spec.rb:12<-[0m <-36m#PagesController GET'home'应该有正确的标题< - [0m < - [31mrspec ./spec/controllers/pages_controller_spec.rb:25<-[0m < - 36m#PagesController GET'contact'应该有正确的标题< - [0m < - [31mrspec ./spec/controllers/pages_controller_spec.rb:38<-[0m <-36m#PagesController GET'contact'should have the right title < - [0米 – 2013-04-19 08:47:05

相关问题