4 Matching Annotations
  1. Aug 2023
  2. Jul 2023
    1. # if contract is passed use contract.start_date as date # Date.current otherwise # if date is given, the block is ignored. date { @overrides[:contract]&.start_date || Date.current }
    1. This lets your test express a concept (similar to a trait), without knowing anything about the implementation: FactoryBot.create(:car, make: 'Saturn', accident_count: 3) FactoryBot.create(:car, make: 'Toyota', unsold: true) IMO, I would stick with traits when they work (e.g. unsold, above). But when you need to pass a non-model value (e.g. accident_count), transient attributes are the way to go.

      traits and transient attributes are very similar

      traits are kind of like boolean (either has it or doesn't) transient attribute flags

  3. Jul 2020