Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

add invokes(&block) to support fakes

#48

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.

Reported by David Chelimsky · May 13th, 2009 @ 02:40 PM

State: new
Milestone: none
Assigned to: nobody

Activity

  1. James Mead
    James Mead

    See the thread I've started on the mailing list [1].

    Cheers, James.

    [1] http://rubyurl.com/8cN1

    May 16th, 2009 @ 04:59 PM

  2. David Chelimsky
    David Chelimsky

    Thanks James - I'll keep an eye on that thread.

    Cheers,
    David

    May 16th, 2009 @ 05:06 PM

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.