Rspec 为什么这个规范在应该通过的时候失败了?

Rspec 为什么这个规范在应该通过的时候失败了?,rspec,Rspec,我在rspec中遇到这个错误。但是,代码应该正在传递。Rspec抱怨的所有选择器都存在 FF.FFFFFF Failures: 1) StaticPages Home page should have the h1 'Sample App' Failure/Error: page.should have_selector('h1', text: 'Sample App') expected css "h1" with text "Sample App" to r

我在rspec中遇到这个错误。但是,代码应该正在传递。Rspec抱怨的所有选择器都存在

FF.FFFFFF

Failures:

  1) StaticPages Home page should have the h1 'Sample App'
     Failure/Error: page.should have_selector('h1', text:  'Sample App')
       expected css "h1" with text "Sample App" to return something
     # ./spec/requests/static_pages_spec.rb:9:in `block (3 levels) in <top (required)>'

  2) StaticPages Home page should have the base title
     Failure/Error: page.should have_selector('title', text:  "Ruby on Rails Tutorial Sample App")
       expected css "title" with text "Ruby on Rails Tutorial Sample App" to return something
     # ./spec/requests/static_pages_spec.rb:14:in `block (3 levels) in <top (required)>'

  3) StaticPages Help page should have the h1  'Help'
     Failure/Error: page.should have_selector('h1',text:  "Help")
       expected css "h1" with text "Help" to return something
     # ./spec/requests/static_pages_spec.rb:28:in `block (3 levels) in <top (required)>'

  4) StaticPages Help page should have the title 'Help'
     Failure/Error: page.should have_selector('title', text:  "Ruby on Rails Tutorial Sample App | Help")
       expected css "title" with text "Ruby on Rails Tutorial Sample App | Help" to return something
     # ./spec/requests/static_pages_spec.rb:33:in `block (3 levels) in <top (required)>'

  5) StaticPages About page should have the h1 'About us' 
     Failure/Error: page.should have_selector('h1', text:  'About Us')
       expected css "h1" with text "About Us" to return something
     # ./spec/requests/static_pages_spec.rb:41:in `block (3 levels) in <top (required)>'

  6) StaticPages About page should have the title 'About Us'
     Failure/Error: page.should have_selector('title', text:  "Ruby on Rails Tutorial Sample App | About Us")
       expected css "title" with text "Ruby on Rails Tutorial Sample App | About Us" to return something
     # ./spec/requests/static_pages_spec.rb:46:in `block (3 levels) in <top (required)>'

  7) StaticPages Contact pages should have the h1 'Contact'
     Failure/Error: page.should have_selector('h1', text:  'Contact')
       expected css "h1" with text "Contact" to return something
     # ./spec/requests/static_pages_spec.rb:53:in `block (3 levels) in <top (required)>'

  8) StaticPages Contact pages Should have the title page 'Contact'
     Failure/Error: page.should have_selector('title',
       expected css "title" with text "Ruby on Rails Tutorial Sample App | Contact" to return something
     # ./spec/requests/static_pages_spec.rb:59:in `block (3 levels) in <top (required)>'

Finished in 0.31051 seconds
9 examples, 8 failures

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:7 # StaticPages Home page should have the h1 'Sample App'
rspec ./spec/requests/static_pages_spec.rb:12 # StaticPages Home page should have the base title
rspec ./spec/requests/static_pages_spec.rb:26 # StaticPages Help page should have the h1  'Help'
rspec ./spec/requests/static_pages_spec.rb:31 # StaticPages Help page should have the title 'Help'
rspec ./spec/requests/static_pages_spec.rb:39 # StaticPages About page should have the h1 'About us' 
rspec ./spec/requests/static_pages_spec.rb:44 # StaticPages About page should have the title 'About Us'
rspec ./spec/requests/static_pages_spec.rb:51 # StaticPages Contact pages should have the h1 'Contact'
rspec ./spec/requests/static_pages_spec.rb:56 # StaticPages Contact pages Should have the title page 'Contact'
home.html.erb视图

<div> 
  <h1>Welcome to the Sample App</h1>
    <h2>This is the home page for the
      <a href="http://railstutorial.org">Ruby on Rails Tutorial</a>
      sample application
    <h2>
      <%= link_to "Sign up now!", '#', class: "btn btn-large btn-primary"%>
 </div> 

 <%= link_to image_tag("rails.png", alt:  "Rails"), 'http://rubyonrails.org' %>

欢迎使用示例应用程序
这是网站的主页
示例应用程序
contact.html.erb

<% provide(:title, 'Contact' ) %>
<h1>Contact</h1>
<p>
  Contact Ruby on rails tutorial about he sample app at the 
  <a href="http://railstutorial.org/contact">contact page</a>
</p>
<% provide(:title,'About Us') %>
  <h1>About Us</h1>
  <p>
    <a href="http://railstutorial.orb">Ruby on Rails Tutorial</a>
    is a project to make a book and screencasts to teach web development 
    <a href="http://rubyonrails.org">Ruby on Rails</a> This
    is the sampel app for the tutorial
  </p>

接触

有关示例应用程序的详细信息,请联系RubyonRails教程

about.html.erb文件

<% provide(:title, 'Contact' ) %>
<h1>Contact</h1>
<p>
  Contact Ruby on rails tutorial about he sample app at the 
  <a href="http://railstutorial.org/contact">contact page</a>
</p>
<% provide(:title,'About Us') %>
  <h1>About Us</h1>
  <p>
    <a href="http://railstutorial.orb">Ruby on Rails Tutorial</a>
    is a project to make a book and screencasts to teach web development 
    <a href="http://rubyonrails.org">Ruby on Rails</a> This
    is the sampel app for the tutorial
  </p>

关于我们

是一个制作书籍和屏幕广播的项目,用于教授web开发
这
是教程的sampel应用程序


改为
在测试中获取
尝试使用
访问
方法:

您是否知道答案?在同一教程中可能存在相同的问题,尽管只是标题。