I want to define Fabricator for class has namespace like 'Foo::Bar'.
Tell me the way it can work.
Here my codes.
models/foo.rb
class Foo
include Mongoid::Document
embedded_in :foo_container, polymorphic: true
field :xxx ....
end
models/foo/bar.rb
class Foo::Bar < Foo
field :yyy ....
field :zzz ....
end
data/fabricators/foo_bar_fabricator.rb
Fabricator(:foo_bar, class_name: 'Foo::Bar') do
yyy 'MyString'
zzz 'MyString'
end
When I tried to create Fabricatior object on parino console but error occurred.
> Fabricate(:foo_bar)
> NoMethodError: undefined method `new?' for nil:NilClass
.... stack messages
When I tried to create other Fabricator object wasn't namespace class like 'User', it went right.