Ruby on rails 卡在第5章或RoR Hartl';s教程填写布局和静态页面规范rspec错误

Ruby on rails 卡在第5章或RoR Hartl';s教程填写布局和静态页面规范rspec错误,ruby-on-rails,rspec,railstutorial.org,Ruby On Rails,Rspec,Railstutorial.org,这件事我已经坚持了三天了。我可能已经阅读了stackoverflow上与错误和第5章相关的每一个线程,但似乎找不到修复方法 我一直在犯这个错误 Failures: 1) Static pages should have the right links on the layout Failure/Error: page.should have_selector 'h1', text: 'Sample App' expected css "h1" with text "

这件事我已经坚持了三天了。我可能已经阅读了stackoverflow上与错误和第5章相关的每一个线程,但似乎找不到修复方法

我一直在犯这个错误

Failures:

  1) Static pages should have the right links on the layout
     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:66:in `block (2 levels) in <top (required)>'

  2) Static pages About Page 
     Failure/Error: it { should_not have_selector 'title', text: '| About Us' }
       expected css "title" with text "| About Us" not to return anything
     # ./spec/requests/static_pages_spec.rb:40:in `block (3 levels) in <top (required)>'

  3) Static pages About Page it should behave like all static pages 
     Failure/Error: it { should have_selector('h1', text: heading) }
       expected css "h1" with text "Sample App" to return something
     Shared Example Group: "all static pages" called from ./spec/requests/static_pages_spec.rb:39
     # ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'

  4) Static pages Home page 
     Failure/Error: it { should_not have_selector 'title', text: '| Home' }
       expected css "title" with text "| Home" not to return anything
     # ./spec/requests/static_pages_spec.rb:19:in `block (3 levels) in <top (required)>'

  5) Static pages Contact Page 
     Failure/Error: it {should_not have_selector 'title', text:'| Contact Us'}
       expected css "title" with text "| Contact Us" not to return anything
     # ./spec/requests/static_pages_spec.rb:51:in `block (3 levels) in <top (required)>'

  6) Static pages Contact Page it should behave like all static pages 
     Failure/Error: it { should have_selector('h1', text: heading) }
       expected css "h1" with text "Sample App" to return something
     Shared Example Group: "all static pages" called from ./spec/requests/static_pages_spec.rb:50
     # ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'

  7) Static pages Help Page 
     Failure/Error: it { should_not have_selector 'title', text: ' | Help' }
       expected css "title" with text " | Help" not to return anything
     # ./spec/requests/static_pages_spec.rb:29:in `block (3 levels) in <top (required)>'

  8) Static pages Help Page it should behave like all static pages 
     Failure/Error: it { should have_selector('h1', text: heading) }
       expected css "h1" with text "Sample App" to return something
     Shared Example Group: "all static pages" called from ./spec/requests/static_pages_spec.rb:28
     # ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'

Finished in 0.36621 seconds
13 examples, 8 failures

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:54 # Static pages should have the right links on the layout
rspec ./spec/requests/static_pages_spec.rb:40 # Static pages About Page 
rspec ./spec/requests/static_pages_spec.rb:8 # Static pages About Page it should behave like all static pages 
rspec ./spec/requests/static_pages_spec.rb:19 # Static pages Home page 
rspec ./spec/requests/static_pages_spec.rb:51 # Static pages Contact Page 
rspec ./spec/requests/static_pages_spec.rb:8 # Static pages Contact Page it should behave like all static pages 
rspec ./spec/requests/static_pages_spec.rb:29 # Static pages Help Page 
rspec ./spec/requests/static_pages_spec.rb:8 # Static pages Help Page it should behave like all static pages 
故障:
1) 静态页面应该在布局上有正确的链接
失败/错误:第页应具有选择器“h1”,文本:“示例应用”
预期css“h1”和文本“示例应用程序”返回某些内容
#./spec/requests/static\u pages\u spec.rb:66:in'block(2层)in'
2) 静态页面关于页面
失败/错误:它{不应该有选择器'title',文本:'About Us'}
预期css“标题”和文本“关于我们”不会返回任何内容
#./spec/requests/static\u pages\u spec.rb:40:in'block(3层)in'
3) 静态页面关于页面它的行为应该与所有静态页面一样
失败/错误:它{应该有_选择器('h1',文本:标题)}
预期css“h1”和文本“示例应用程序”返回某些内容
共享示例组:./spec/requests/static\u pages\u spec.rb:39调用的“所有静态页面”
#./spec/requests/static\u pages\u spec.rb:8:in'block(3层)in'
4) 静态页面主页
失败/错误:它{不应该有_选择器'title',文本:'| Home'}
预期带有文本“| Home”的css“title”不会返回任何内容
#./spec/requests/static\u pages\u spec.rb:19:in'block(3层)in'
5) 静态页面联系人页面
失败/错误:它{应该没有选择器'title',文本:''Contact Us'}
预期css“标题”带有文本“|联系我们”不会返回任何内容
#./spec/requests/static\u pages\u spec.rb:51:in'block(3层)in'
6) 静态页面联系页面它的行为应该与所有静态页面一样
失败/错误:它{应该有_选择器('h1',文本:标题)}
预期css“h1”和文本“示例应用程序”返回某些内容
共享示例组:./spec/requests/static\u pages\u spec.rb:50调用的“所有静态页面”
#./spec/requests/static\u pages\u spec.rb:8:in'block(3层)in'
7) 静态页面帮助页面
失败/错误:它{不应该有选择器'title',文本:''Help'}
预期带有文本“| Help”的css“title”不会返回任何内容
#./spec/requests/static\u pages\u spec.rb:29:in'block(3层)in'
8) 静态页面帮助页面它的行为应该与所有静态页面一样
失败/错误:它{应该有_选择器('h1',文本:标题)}
预期css“h1”和文本“示例应用程序”返回某些内容
共享示例组:./spec/requests/static\u pages\u spec.rb:28调用的“所有静态页面”
#./spec/requests/static\u pages\u spec.rb:8:in'block(3层)in'
以0.36621秒完成
13例,8例失败
失败的示例:
rspec./spec/requests/static_pages_spec.rb:54#静态页面应该在布局上有正确的链接
rspec./spec/requests/static_pages_spec.rb:40#static pages关于页面
rspec./spec/requests/static_pages_spec.rb:8#关于页面的静态页面它的行为应该与所有静态页面一样
rspec./spec/requests/static_pages_spec.rb:19#static pages主页
rspec./spec/requests/static_pages_spec.rb:51#static pages联系页面
rspec./spec/requests/static_pages_spec.rb:8#static pages Contact Page它的行为应该与所有静态页面一样
rspec./spec/requests/static_pages_spec.rb:29#static pages帮助页面
rspec./spec/requests/static_pages_spec.rb:8#static pages Help Page它的行为应该与所有静态页面一样
我已经检查了所有相关文件中的语法,我已经检查了任何打字错误,特别是双引号和单引号。因为我已经研究了三天,在这里或其他地方都没有找到任何好的解决方案,我不确定我到底哪里出了问题,这里没有粘贴代码,而是我在github上的应用程序链接,github是最新的工作分支 谢谢你的帮助!

我刚刚将您的github存储库克隆到我的Mac上,选择了Ruby版本,运行了
bundle instal
,并成功运行了您的测试,如下所示。你使用的是什么版本的Ruby

new-host:stackoverflow_sample_app palfvin$ rails c
Loading development environment (Rails 3.2.13)
1.9.3-p194 :001 > quit
new-host:stackoverflow_sample_app palfvin$ rspec spec/*
.........

Finished in 0.27565 seconds
9 examples, 0 failures

Randomized with seed 61309

new-host:stackoverflow_sample_app palfvin$ ls spec/*
spec/spec_helper.rb

spec/requests:
static_pages_spec.rb
new-host:stackoverflow_sample_app palfvin$ 

您好,我正在使用ruby 1.9.3p194Rails版本如何?另外,您可以在访问页面后尝试打印页面/响应,看看您得到了什么。嗨,Peter,我正在使用Rails 3.2.13