Francois Beausoleil
2006-Nov-28 15:02 UTC
[mocha-developer] Partial matches in expectations
Hi ! I would like to ascertain the following in a test case: @template.expects(:content_tag).with(:fieldset, :__any_arguments__i_dont_care) Is it possible to do so ? If so how ? If not, is it something the community wants ? Is it useful ? Thanks ! -- Fran?ois Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/
On 28/11/06, Francois Beausoleil <francois.beausoleil at gmail.com> wrote:> > I would like to ascertain the following in a test case: > > @template.expects(:content_tag).with(:fieldset, > :__any_arguments__i_dont_care) > > Is it possible to do so ? If so how ?It should be possible to do this as follows... @template.expects(:content_tag).with { |*params| params.first == :fieldset } The with() block should return true or false depending on whether the expectation should match. -- James. http://blog.floehopper.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20061128/890622e0/attachment.html
Francois Beausoleil
2006-Nov-28 15:54 UTC
[mocha-developer] Partial matches in expectations
Hello James ! 2006/11/28, James Mead <jamesmead44 at gmail.com>:> @template.expects(:content_tag).with { |*params| params.first == :fieldset }Thanks. I remember reading that somewhere before. You should have told me to read the friggin'' manual :) Thanks, works great ! -- Fran?ois Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/