Using factory bot, creating variables like so :
let!(:deal) { create(:deal) }
The following sample :
expect {
...stuff that effectively associate an attachment to the deal...
}.to change { deal.attachments.length }.from(0).to(1)
does not pass.
The same testing, while reloading the deal :
...to change { deal.reload.attachments.length } ...
does pass.
In my other occasions, I'm ending up using this reload method. It feel like this is not the right way to go at all, and that i'm missing the point
What would be the correct way to test changes on records without having to reload them ?
Aucun commentaire:
Enregistrer un commentaire