[rspec-users] default to just call the method?

Pat Maddox mailinglists at patmaddox.com
Mon Jan 18 04:31:09 EST 2010


On Jan 15, 2010, at 6:19 AM, Ashley Moran wrote:

> 
> 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.

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


More information about the rspec-users mailing list