Skip to content

How to use Alchemy factories in my app specs? #2440

Answered by phantomwhale
phantomwhale asked this question in Q&A
Discussion options

You must be logged in to vote

Looks like factory_bot_rails was the problem - it loads the factory definitions when require_relative '../config/environment' executes, which causes the chicken and egg problem for our app.

This problem might not apply to other rails apps, as I also uncovered that we have the following in OUR factory definitions:

FactoryBot.modify do
  factory :alchemy_content do
    trait :essence_link do
      essence_type { "Alchemy::EssenceLink" }
      association :essence, factory: :alchemy_essence_link
    end
  end
end

Meaning we need the alchemy factory definitions loaded before we load ours. Going back to just factory_bot gem, and adding in the recommend lines ALMOST works; due to us modifying …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tvdeyen
Comment options

Answer selected by tvdeyen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants