vendredi 26 juin 2015

How to stub rails service's attributes?

I have a transaction inside a service and I need to test the rollback of the database if the process fails. So, I need to stub an attribute called '@status' to return false.

I know how to stub Models, but this way below don't worked for me:

Model.any_instance.stub(:method).and_return(result)

There is a way of stub it without add other gems? I'm already using the shoulda_matchers gem.

Aucun commentaire:

Enregistrer un commentaire