[rspec-users] Stubbing out method for all instances

David Smalley david.smalley.lists at googlemail.com
Tue Mar 27 05:12:15 EDT 2007


I am using the acts_as_state_machine plugin to control state of an  
object in my app, however when testing this I need to be able to stub  
out the guard conditions so that state will change when I fire off an  
event without depending on other models.

Guard conditions simply return true or false so I have an instance  
method:

def encoded?
   <check state of other objects>
   return true or false
end

However I cannot find a way to stub out this method properly. Ideally  
I wish to do something that I expect I could do with Test::Unit mocks  
and just replace the encoded? instance method for all objects that  
might use it to just return true.

Any ideas?

David




More information about the rspec-users mailing list