Skip to content
has207 edited this page Feb 22, 2011 · 76 revisions

This page has moved to:

http://has207.github.com/flexmock/user-guide.html

Not yet released new features

Replacing methods with custom functions

There are times when it is useful to replace a method with a custom lambda or function in order to return custom values based on provided arguments or a global value that changes between method calls.

flexmock(some_object).should_receive('some_method').replace_with(lambda x, y, z: y == 5)

new_instances parameter deprecated in favor of new_instances method

# old and deprecated
flexmock(SomeClass, new_instances=fake_object)

# new hotness
flexmock(SomeClass).new_instances(fake_object)
Clone this wiki locally