#48 new
David Chelimsky

add invokes(&block) to support fakes

Reported by David Chelimsky | 2009-05-13 14:40:49 UTC

The "fake" pattern (http://xunitpatterns.com/Fake%20Object.html) is an extension of stub where the method is actually implemented (by the tester) rather than simply returning a canned value.

The attached patch supports the following:

obj = stub()
obj.stubs(:foo).invokes do |bar|
  if bar == :one_thing
    :value_for_one_thing
  else
    :value_for_anything_else
  end
end

This allows you to handle multiple and differing calls to the same method in a single, clear, explicit declaration.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

A mocking & stubbing library for Ruby.

* GitHub repository
* Documentation
* Mailing List

People watching this ticket

Attachments

Pages