使用guard/spork/rspec/factory_girl 运行rails 3.2.3,并在我的规范助手中包含以下内容:
Spork.prefork do
...
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.include Devise::TestHelpers, :type => :controller
...
end
end
并有适当的模型/工厂设置,以便这应该工作:
describe "GET index" do
describe "as logged in Person without Attendee record" do
@person = create :person
sign_in @person
it "redirects to Attendee new page" do
visit school_programs_root
current_path.should == new_school_programs_attendees
end
end
end
但是,当我运行规范时,我得到:
Exception encountered: #<NoMethodError: undefined method `create' for #<Class:0x007f860825a798>>
当我将规范的第 3 行更改为:
@person = FactoryGirl.create :person
工厂已创建,但我得到:
Exception encountered: #<NoMethodError: undefined method `sign_in' for #<Class:0x007fcee4364b50>>
所有这些都表明我的控制器规格没有加载助手。