我正在关注Michael Hartl教程的第5章。当我从根目录运行以下内容时,
$ bundle exec rspec spec/
我收到以下错误:
No DRb server is running. running in local process instead ...
c:/sites/sample_app/spec/helpers/applcation_helper_spec.rb:1:in '<top required>>': uninitialized constant ApplicationHelper (NameError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:746:in 'loud'
.
.
我认为我应该尝试隔离哪些文件失败了,我发现有2个文件出现了上述错误(其余的都运行了测试并且传递了0失败)。那些失败的是:
1)spec / helpers / application_helper_spec.rb
describe ApplicationHelper do
describe "full_title" do
it "should include the page name" do
full_title("foo").should =~ /foo/
end
it "should include the base name" do
full_title("foo").should =~ /^Ruby on Rails Tutorial Sample App/
end
it "should not include a bar for the home page" do
full_title("").should_not =~ /\|/
end
end
end
2)spec / support / utilities.rb
include ApplicationHelper
答案 0 :(得分:1)
在阅读之后,我发现rspec需要spork运行(不确定为什么它适用于某些测试,而不是其他测试?)。我忘了要求spec_helper,所以我在application_helper_spec.rb的第一行插入它并且它有效。
require 'spec_helper'