Any interest in the following idea?
a.should include?(“1:4”) # if there’s no matcher called include? then
just call include?
or something along those lines?
-r
Any interest in the following idea?
a.should include?(“1:4”) # if there’s no matcher called include? then
just call include?
or something along those lines?
-r
On Jan 12, 2010, at 10:49 pm, rogerdpack wrote:
a.should include?(“1:4”) # if there’s no matcher called include? then
just call include?
Am I right thinking that this would mean writing a method_missing that
creates a matcher for every unhandled message on the example object
(whatever scope the #it block runs in)? If so, that could produce
surprising behaviour if methods were silently turned into matchers and
ignored.
Maybe if you restricted it to ? methods it would not be so bad. But
then, that’s the point of the be_* handler. The only problem is that
#include? is a verb not an adjective/noun. Can’t say I’ve come across
many of them, so it might be better in these cases to just write a
method #a_container_for? ?
Ashley
–
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
On Tue, Jan 12, 2010 at 5:49 PM, rogerdpack [email protected]
wrote:
Any interest in the following idea?
a.should include?(“1:4”) # if there’s no matcher called include? then
just call include?or something along those lines?
-1
You can already say
a.should include(“1:4”)
which is clearer IMHO.
–
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: Rick DeNatale - Developer - IBM | LinkedIn
On 14 Jan 2010, at 17:02, Rick DeNatale wrote:
-1
You can already say
a.should include(“1:4”)
which is clearer IMHO.
I assume Roger was referring to the general case though (which I still
don’t like) - and just happened to pick an example with an existing
matcher.
–
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
On Jan 15, 2010, at 6:19 AM, Ashley M. wrote:
I assume Roger was referring to the general case though (which I still don’t like) - and just happened to pick an example with an existing matcher.
If that’s the case then I’d say it would be worth making a little macro
to try it out. Something like
define_simple_predicate_matcher :rise_from_the_ashes?
It would need to define a simple matcher, allowing you to do
Phoenix.new.should rise_from_the_ashes?
which would naturally expand to Phoenix.new.rise_from_the_ashes?.should
be_true
Roger, if you’re just talking about include?, follow Rick’s suggestion.
If you’re talking about arbitrary predicates, then you can accomplish it
in your own codebase with some simple metaprogramming, and see if it
catches on with other folks.
Pat
On Jan 18, 2010, at 9:31 am, Pat M. wrote:
define_simple_predicate_matcher :rise_from_the_ashes?
As an extension, how about:
define_simple_predicate_matcher :risen_from_the_ashes =>
:rise_from_the_ashes?
Also, in general, I think specs look better without ? symbols on
methods, my preference though
Ashley
–
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
On Jan 18, 2010, at 3:12 pm, David C. wrote:
I’d rather not add a new DSL for the few cases in which we want to
essentially delegate a predicate. We can already do this with the
matcher DSL:
I think Pat was just suggesting Roger try this in his own code. It’s
not something I especially want in RSpec, that was just a suggestion how
Roger could play with the macro idea.
Ashley
–
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
On Jan 18, 2010, at 7:12 AM, David C. wrote:
I’d rather not add a new DSL for the few cases in which we want to
essentially delegate a predicate. We can already do this with the
matcher DSL:Spec::Matchers.define :risen_from_the_ashes do
match {|actual| actual.risen_from_the_ashes?}
endThis is better aligned w/ other matchers, more clear as to what it
does, and isn’t much more code.
This was a suggestion for OP to add to his own codebase, not RSpec, if
he wanted to make the matcher definition even more concise.
Pat
On Mon, Jan 18, 2010 at 2:33 PM, Pat M. [email protected]
wrote:
This is better aligned w/ other matchers, more clear as to what it
does, and isn’t much more code.This was a suggestion for OP to add to his own codebase, not RSpec, if he wanted to make the matcher definition even more concise.
Understood. Thx.
On Mon, Jan 18, 2010 at 9:03 AM, Ashley M.
[email protected] wrote:
On Jan 18, 2010, at 9:31 am, Pat M. wrote:
define_simple_predicate_matcher :rise_from_the_ashes?
As an extension, how about:
define_simple_predicate_matcher :risen_from_the_ashes => :rises_from_the_ashes?
I’d rather not add a new DSL for the few cases in which we want to
essentially delegate a predicate. We can already do this with the
matcher DSL:
Spec::Matchers.define :risen_from_the_ashes do
match {|actual| actual.risen_from_the_ashes?}
end
This is better aligned w/ other matchers, more clear as to what it
does, and isn’t much more code.
FWIW,
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs