2013-03-30 6 views
2

RSpec과 함께 사용할 FactoryGirl의 튜토리얼 및 문서를 따라했습니다.RSpec 및 FactoryGirl이있는 레일즈 엔진

describe "GenericRecipesController" do 
    describe "GET 'index'" do 
    it "displays list of generic recipes" do 
     generic_recipe = FactoryGirl.create(:generic_recipe) 
     visit '/recipe' 
     response.should be_success 
    end 
    end 
end 

그리고 오류 : code is there

GenericRecipesController GET 'index' displays list of generic recipes 
Failure/Error: generic_recipe = FactoryGirl.create(:generic_recipe) 
NameError: 
    uninitialized constant GenericRecipe 
# ./spec/integration/generic_recipes_spec.rb:8:in `block (3 levels) in <top (required)>' 

나머지 FactoryGirl.create를 사용하려고 할 때 현재 내가 한 오류가 발생합니다.

+0

다음은 질문하기 전에 전체 소스 코드를 사용할 수있는 upvote입니다. – depa

+0

또한 공장 코드를 알려주시겠습니까? – depa

+0

고마워, 공장은 여기에있다 : https://github.com/valk/edible-recipe/blob/master/spec/factories.rb – valk

답변

0

앱에 GenericRecipe 모델이없는 것 같습니다. 공장 소녀가 GenericReciper라는 모델을 찾고 있는데 찾을 수 없습니다.

factory :generic_recipe, class: EdibleRecipe::GenericRecipe do 
    # ... 
end 

내가 모듈

UPD에 중첩 모델에서 문제를 생각 :

+0

나는 그것을 여기에 가지고있다. https://github.com/valk/edible-recipe/blob/master/app/models/edible_recipe/generic_recipe.rb – valk

1

이 시도 할 수있는 파일/스펙/지원/공장에서, 파일 /spec/factories.rb 삭제 .rb make

factory :generic_recipe, class: EdibleRecipe::GenericRecipe do 

테스트를 실행하면 '테이블을로드 할 수 없습니다'라는 메시지가 표시됩니다. 확인

rake db:migrate RAILS_ENV=test 

다시 시도하십시오.

+0

고마워 hellaxe, 시도했지만 아니오. 행운을 빌어 요. ( – valk

+0

정확히 똑같은 대답을 올리려고했는데, 지금 당황 스럽네요. – depa

+0

나도 당황하네요. 발크, 테스트 해 볼만한가요? 레포에서 볼 수 없었어요. – hellaxe

관련 문제