All quizzes
Free quiz · 20 questions in the bank

FactoryBot quiz

Test your FactoryBot knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

How does FactoryBot let a test override a factory's default attribute value?

In this round
  1. How does FactoryBot let a test override a factory's default attribute value?
  2. What is the difference between `FactoryBot.build(:user)` and `FactoryBot.create(:user)`?
  3. What does `FactoryBot.attributes_for(:user)` return, as distinct from `build` or `create`?
  4. Why might a team define multiple related factories with inheritance (e.g. `factory :admin_user, parent: :user do ... end`) rather than one large factory with many conditional branches?
  5. Why is it good practice to name FactoryBot factories after the model they represent (e.g. `factory :user` for the `User` model), unless there's a specific reason not to?
  6. Why might a test prefer `FactoryBot.build(:user)` over `FactoryBot.create(:user)` when persistence isn't actually needed?
  7. Why is it commonly recommended to keep factory-defined default attribute values minimal/valid rather than piling on excessive complexity?
  8. What is an "association" in a FactoryBot factory, such as `association :author, factory: :user`?
  9. What does `FactoryBot.create_list(:user, 5)` do?
  10. What is FactoryBot primarily used for?
  11. How does FactoryBot compare to Rails' built-in fixture files (YAML-based) as a way to generate test data?
  12. What risk does relying on overly elaborate, deeply-nested factory setups introduce for test readability?
Gaps to close?
Read the curated FactoryBot notes — core concepts, patterns, interview prep.
FactoryBot notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web