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.

[#10413] Mock Blocks

#5

Date: 2007-04-27 16:39 Sender: Brian Takita

Allow mock expectations to be defined within a block. This syntax is similar to ActiveRecord and Markaby.

In these examples, the block is instance evaled with the binding of the mock.


mock('The new mock') do
  foo(1,2) {:bar}
  baz(3,4).returning(:foobar)
end

User.mocks do
  find('3').once {user}
  destroy(7)
end

An alternate syntax does not instance eval the block.


mock('The new mock') do |m|
  m.foo(1,2) {:bar}
  m.baz(3,4).returning(:foobar)
end

User.mocks do |m|
  m.find('3').once {user}
  m.destroy(7)
end

This feature request is coupled with the merge with block into the method name expectation feature. http://rubyforge.org/tracker/ind...

Reported by James Mead · January 1st, 2009 @ 06:26 PM

State: new
Milestone: none
Assigned to: nobody

Activity

No comments yet.

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.