Another approach is to use Rails built-in roles, such as:
When a bulk assignment FactoryGirl transfers this role, making this pattern possible.
Pros: Keeps factories fast, simple and clean (less code in callbacks)
Cons: You change your model code for your tests :(
Some unverified suggestions for accessing Con:
- You can re-open the class just above the factory.
- You can reopen the class in [test | spec] _helper
Chip
source share