[mocha-developer] Fwd: [ mocha-Feature Requests-15021 ] without or not params matcher

James Mead jamesmead44 at gmail.com
Thu Oct 25 09:04:11 EDT 2007


---------- Forwarded message ----------
From: noreply at rubyforge.org <noreply at rubyforge.org>
Date: 25 Oct 2007 14:01
Subject: [ mocha-Feature Requests-15021 ] without or not params matcher
To: noreply at rubyforge.org

Feature Requests item #15021, was opened at 2007-10-24 15:33
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7480&aid=15021&group_id=1917

Category: Interface Improvements (example)
Group: None
Status: Open
Priority: 3
Submitted By: Jerry Vos (jerryvos)
Assigned to: Nobody (None)
Summary: without or not params matcher

Initial Comment:
Would be nice if you could do



MyClass.expects(:create!).without(hasKey(:property1))



or something like



MyClass.expects(:create!).with(not(hasKey(:property1)))



MyClass.expects(:create!).with(not.hasKey(:property1)))



But you can't use not because not is a ruby keyword.



The Not Matcher is just something like:



class Not # :nodoc:



  def initialize(matcher)

    @matcher = matcher

  end



  def ==(parameter)

    !(matcher == parameter)

  end



  def mocha_inspect

    "not(#{@matcher.mocha_inspect})"

  end



end



----------------------------------------------------------------------

>Comment By: James Mead (jamesmead)
Date: 2007-10-25 13:01

Message:
Hi Jerry,



Thanks for the suggestions. I had wanted to add not() a while ago, but ran
into the keyword issue. I've just committed revision 191 with Not() instead.
It isn't great, but it's the best I can think of at the moment. What do you
think?



I don't think the without() works because you may want to negate only some
of your matchers.



Cheers, James.

----------------------------------------------------------------------

You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7480&aid=15021&group_id=1917


-- 
James.
http://blog.floehopper.org
http://tumble.floehopper.org


More information about the mocha-developer mailing list