I used the rspec test to be feasible, but the problem is that the verification code is not executed after the simulation, I don't know how to solve it.
I think that what Leonardo said is a good solution... I prefer the other just because you don't need to write allow(store).to receive(:create) before.
Other option is to create a custom "spy" that can do whatever you want, like...
But I think that in this case I prefer the other two solutions.
Abut the clean architecture reference...
I feel that this code is to make the model as the entity, the corresponding Product class and class method as the database interface. Closer to the architectural idea of the illustration. The original rails are organized with data as the center, or the database is the center.
Yes! this is more or less what I do and propose... To use the model more or less like an entity and the Product class as the Database interface.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi @chenge , thanks for sharing my article =) ... although apparently the link is broken dev.to/bhserna/how-to-test-that-yo...
About the verification code...
I think that what Leonardo said is a good solution... I prefer the other just because you don't need to write
allow(store).to receive(:create)
before.Other option is to create a custom "spy" that can do whatever you want, like...
But I think that in this case I prefer the other two solutions.
Abut the clean architecture reference...
Yes! this is more or less what I do and propose... To use the model more or less like an entity and the Product class as the Database interface.