Simple Mock: Override_method
Join the DZone community and get the full member experience.Join For Free
Note: ALL code samples in this post were hijacked from: http://www.karmiccoding.com/articles/2006/03/11/under-the-hood-with-ruby-partial-mock-objects-for-unit-testing
# Overrides the method +method_name+ in +obj+ with the passed block def override_method(obj, method_name, &block) # Get the singleton class/eigenclass for 'obj' klass = class <
Outputs: (0) I'm NOT okay! (1) I'm okay! (2) I'm okay! (3) I'm okay! (4) I'm okay!
Opinions expressed by DZone contributors are their own.