Ruby on rails 3 在第5章的版面链接部分添加页面时出错(Michael Hartl)

Ruby on rails 3 在第5章的版面链接部分添加页面时出错(Michael Hartl),ruby-on-rails-3,rspec-rails,railstutorial.org,Ruby On Rails 3,Rspec Rails,Railstutorial.org,我在MichaelHartl的RoR教程的第5.3节中添加了一个联系人页面。我运行了$bundle exec rspec spec/requests/static\u pages\u spec.rb。我想不出这个错误。我在spec/requests/static_pages_spec.rb中进行了更改,为联系人页面添加了适当的路由、操作,并编辑了联系人页面的视图。这是输出: Failures: 1) Static Pages Contact page should have the h1

我在MichaelHartl的RoR教程的第5.3节中添加了一个联系人页面。我运行了
$bundle exec rspec spec/requests/static\u pages\u spec.rb
。我想不出这个错误。我在spec/requests/static_pages_spec.rb中进行了更改,为联系人页面添加了适当的路由、操作,并编辑了联系人页面的视图。这是输出:

Failures:

  1) Static Pages Contact page should have the h1 'Contact'
 Failure/Error: visit '/static_pages/contact'
 ActionView::Template::Error:
   /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ',', expecting ')'
   ...putBuffer.new; provide (:title, 'Contact') 
   ...                               ^
   /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ')', expecting keyword_end
   ...ew; provide (:title, 'Contact') 
   ...                               ^
 # <internal:prelude>:10:in `synchronize'
 # ./spec/requests/static_pages_spec.rb:56:in `block (3 levels) in <top (required)>'

  2) Static Pages Contact page should have the title 'Contact'
 Failure/Error: visit '/static_pages/contact'
 ActionView::Template::Error:
   /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ',', expecting ')'
   ...putBuffer.new; provide (:title, 'Contact') 
   ...                               ^
   /Users/themaktravels/rails_projects/happy_app/app/views/static_pages/contact.html.erb:1: syntax error, unexpected ')', expecting keyword_end
   ...ew; provide (:title, 'Contact') 
   ...                               ^
 # <internal:prelude>:10:in `synchronize'
 # ./spec/requests/static_pages_spec.rb:61:in `block (3 levels) in <top (required)>'

Finished in 0.53514 seconds
9 examples, 2 failures

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:55 # Static Pages Contact page should have the h1 'Contact'
rspec ./spec/requests/static_pages_spec.rb:60 # Static Pages Contact page should have the title 'Contact'
在RoR教程中,这是在
静态页面\u spec.rb
中指导您的内容:

 describe "Contact page" do

     it "should have the h1 'Contact'" do
     visit '/static_pages/contact'
     page.should have_selector('h1', text: 'Contact')
  end

     it "should have the title 'Contact'" do
     visit '/static_pages/contact'
     page.should have_selector('title',
                text: "Ruby on Rails Tutorial Sample App | Contact")
  end
我在
static\u pages\u spec.rb
中所做的唯一更改是(1)将“Sample App”改为“Happy App”,以及(2)“text:”代替了“:text=>”,这样格式在
static\u pages\u spec.rb
中的整个代码中都是一致的。故障排除时,我在两个“文本”版本之间切换,得到了相同的结果

关于我应该寻找什么来解决错误,有什么建议吗?此外,我不确定如何读取错误消息,即错误的第一部分是否显示正确的方法,反之亦然


谢谢大家!

您的电话线上似乎有不必要的空间。应该是

<% provide(:title, 'Contact') %>

不是


您的电话线上似乎有不必要的空间。应该是

<% provide(:title, 'Contact') %>

不是



你的app/views/static\u pages/contact.html.erb视图文件是什么样子的?正如错误所述,您似乎有语法错误。联系在页面上联系RubyonRails教程,了解Happy应用程序

你的app/views/static_pages/contact.html.erb视图文件是什么样子的?正如错误所述,您似乎有语法错误。联系在页面上联系RubyonRails教程,了解Happy应用程序

多谢各位。我看了这么久,甚至没有看到额外的空间。谢谢。我看了这么久,甚至没有看到额外的空间。
<% provide (:title, 'Contact') %>