FactoryGirl Error

I have a class defined in a module.

module Mod class Zed include DataMapper::Resource end end 

For testing, I define a factory.

 #/factories/zed.rb FactoryGirl.define do factory :zed do #code end end 

But when I start testing, I get an error message.

 describe 'Zed' do it "should have ..." do FactoryGirl.create(:zed) end end 

Error:

  Failure/Error: FactoryGirl.create(:zed) NameError: uninitialized constant Zed 

How to check the class that is included in the module? Thanks.

+6
source share
1 answer

You must specify the class when defining the factory as follows:

 FactoryGirl.define do factory :zed, class: Mod::Zed do #code end end 
+11
source

Source: https://habr.com/ru/post/921463/


All Articles