Over a million developers have joined DZone.

Simple Mock: Override_method

DZone's Guide to

Simple Mock: Override_method

Free Resource
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, █)
  # Get the singleton class/eigenclass for 'obj'
  klass = class <
(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.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}