RSpec.describe'Donation Matching',:type=>:modeldocontext'with an amount'dolet(:donation){create(:donation,:with_amount)}endcontext'with no amount'dolet(:donation){create(:donation,:no_amount)}endend
However, I believe that using a shared context is a clearer approach. Defining the amount in a shared context and overriding the amount allows more control over testing use cases.
Using a shared context
donation_spec.rb
123456789101112131415161718
require'support/shared_contexts/donor_with_donation_context'RSpec.describe'Donation Matching',:type=>:modeldoinclude_context'a donor with a donation'context'with an amount'do//donation.amount==10(definedinthesharedcontext)endcontext'with no amount'dolet(:amount){0}//donation.amount==0endcontext'with a gnarly'dolet(:amount){09709780}endend