2012-04-12 85 views
0

我遵循Michael Hartl教程的第5章。当我运行从根目录下面,我的rspec测试不会通过

$ 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)规格/助理/ 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)投机/支持/ utilities.rb

include ApplicationHelper 
+0

我已经回答了我自己的问题,但不能将它张贴另外7小时。 – glennm 2012-04-12 01:12:26

回答

1

阅读各地后,我发现了rspec的需求spork运行(不知道为什么它在某些测试中运行,而不是在其他运行中运行)。我忘记了需要spec_helper,所以我将它插入application_helper_spec.rb的第一行,它工作。

require 'spec_helper' 

Here's the post that lead me to the answer.