无法在 Ruby on Rails 应用程序上运行 Rspec、spork 和自动测试
我正在学习 Michael Hartl 的 Rails 教程,现在正在阅读第 5 章。但是,我无法运行我的 Rspec、spark 和自动测试。当我尝试让它们运行时,我收到一条错误消息:
Paul-Denlingers-MacBook-Pro:sample_app_2 pdenlinger$ rspec spec/
No DRb server is running. Running in local process instead ...
/Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load': /Users/pdenlinger/rails_projects/sample_app_2/spec/controllers/pages_controller_spec.rb:14: syntax error, unexpected keyword_end, expecting $end (SyntaxError)
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:66:in `rescue in run'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:62:in `run'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'
这是什么意思,我该如何修复它?提前致谢!
页面控制器规范.rb
require 'spec_helper'
describe "LayoutLinks" do
it "should have a Home page at '/' do"
get '/'
response.should have_selector('title', :content => "Home")
end
it "should have a Contact page at '/contact' do"
get '/contact'
response.should have_selector('title', :content => "Contact")
end
it "should have a About page at '/about' do"
get '/about'
response.should have_selector('title', :content => "About")
end
it "should have a Help page at '/help' do"
get '/help'
response.should have_selector('title', :content => "Help")
end
end
Am working my way through Michael Hartl's Rails Tutorial and am now in Chapter 5. However, I cannot get my Rspec, spark and auto tests to run. When I try to get them to run, I get an error message:
Paul-Denlingers-MacBook-Pro:sample_app_2 pdenlinger$ rspec spec/
No DRb server is running. Running in local process instead ...
/Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load': /Users/pdenlinger/rails_projects/sample_app_2/spec/controllers/pages_controller_spec.rb:14: syntax error, unexpected keyword_end, expecting $end (SyntaxError)
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:66:in `rescue in run'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:62:in `run'
from /Users/pdenlinger/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'
What does this mean, and how can I fix it? Thanks in advance!
pages_controller_spec.rb
require 'spec_helper'
describe "LayoutLinks" do
it "should have a Home page at '/' do"
get '/'
response.should have_selector('title', :content => "Home")
end
it "should have a Contact page at '/contact' do"
get '/contact'
response.should have_selector('title', :content => "Contact")
end
it "should have a About page at '/about' do"
get '/about'
response.should have_selector('title', :content => "About")
end
it "should have a Help page at '/help' do"
get '/help'
response.should have_selector('title', :content => "Help")
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所有
do
关键字都包含在示例描述中。将:更改为:
并对每个示例重复。
All of your
do
keywords are enclosed in your example descriptions. Change:to:
and repeat for each of your examples.
如果您阅读错误消息,则此文件中似乎缺少
end
:第 14 行
。 @pdenlinger 修复其帖子后更新:
您正在附上 < code>do 关键字在引号中,而你不应该这样做。它应该看起来像这样:
If you read the error message, it looks like you have a missing
end
in this file:at line 14.
Update after @pdenlinger fixed his post:
You are enclosing the
do
keyword in quotes when you shouldn't. It should look like this instead: