James Mead
2007-Oct-25 13:04 UTC
[mocha-developer] Fwd: [ mocha-Feature Requests-15021 ] without or not params matcher
---------- 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
Reasonably Related Threads
- Fwd: [ mocha-Bugs-7834 ] infinte_range.rb makes incorrect assumption about to_f
- Fwd: [ mocha-Feature Requests-5856 ] Stubbing of private methods should be allowed
- Fwd: [ mocha-Feature Requests-7119 ] ability to specify call order
- Fwd: [ mocha-Bugs-16523 ] Ruby 1.9 gives warning
- Fwd: [ mocha-Feature Requests-13763 ] add with_any_arguments method
