4 Matching Annotations
- Aug 2023
-
-
Factory :video_file do file { fixture_file_upload 'test.png', 'image/png' } end
-
- Jul 2023
-
stackoverflow.com stackoverflow.com
-
# 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 }
-
-
stackoverflow.com stackoverflow.com
-
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
-
- Jul 2020