You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FactoryBot throws an error when defining factories that refer to classes within modules in non-Rails applications. FactoryBot will work, but the class used by the factory must be explicitly stated in the full namespace. Simply updating the GETTING_STARTED.md document should be sufficient.
Reproduction Steps
# bar.rb
module Foo
class Bar
...
end
end
# factories.rb
FactoryBot.define do
factory :bar do
...
end
end
Produces this error: NameError: uninitialized constant Bar
Working Code
# bar.rb
module Foo
class Bar
...
end
end
# factories.rb
FactoryBot.define do
factory :bar, class: 'Foo::Bar' do
...
end
end
I'm happy to update GETTING_STARTED.md to explain better and help rookies like me who might get stumped.
The text was updated successfully, but these errors were encountered:
Description
FactoryBot throws an error when defining factories that refer to classes within modules in non-Rails applications. FactoryBot will work, but the class used by the factory must be explicitly stated in the full namespace. Simply updating the GETTING_STARTED.md document should be sufficient.
Reproduction Steps
Produces this error:
NameError: uninitialized constant Bar
Working Code
I'm happy to update GETTING_STARTED.md to explain better and help rookies like me who might get stumped.
The text was updated successfully, but these errors were encountered: