運行軌道3.2.3後衛/叉勺/ RSpec的/ factory_girl並在我的規格幫手如下:FactoryGirl並設計助手不規範工作
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
然而,當我運行spec我得到:
Exception encountered: #<NoMethodError: undefined method `create' for #<Class:0x007f860825a798>>
當我改變李規範的NE 3:
@person = FactoryGirl.create :person
工廠創建的,但我得到:
Exception encountered: #<NoMethodError: undefined method `sign_in' for #<Class:0x007fcee4364b50>>
所有這些都表明,我認爲傭工沒有得到加載我的控制器的規格。
我不再有這些測試,所以不能在我的代碼上測試您的建議。感謝您爲將來可能使用它的任何人提供幫助。 – iliveinapark 2012-06-26 00:49:09