I want to drown out only a specific model, but not just a specific object, but not every instance
eg. This class is 'Person' with the attributes 'name' (string) and 'cool' (boolean). We have two models:
person_bill: name: bill cool: false person_steve: name: steve cool: false
Now I want to drown out only steve, which works well:
p1 = people(:person_steve) p1.stubs(:cool? => true) assert p1.cool?
But if I load the model from the database again, itβs not:
p1 = people(:person_steve) p1.stubs(:cool? => true) p1 = Person.find_by_name p1.name assert p1.cool?
This works, but also affects Bill, which should not:
Person.any_instance.stubs(:cool? => true) assert people(:person_bill).cool?
So, how can I just kill Steve, but anyway? Is there any conditional any_instance like
Person.any_instance { |p| p.name == 'Steve' }.stubs(:cool? => true)
Thanks in advance!
source share