[Rspec-devel] support for arbitrary comparisons

Jay Levitt lists-rspec at shopwatch.org
Wed Sep 6 11:16:55 EDT 2006


David Chelimsky wrote:
> Mike Williams contributed a patch to support arbitrary comparisons.
> This is now in the trunk and will be part of the next release. So you
> will now be able to do this:
> 
> result.should_be < 5
> result.should_be >= 7

This rocks.

> It also supports alternate syntax for should_be, should_match
> 
> result.should == 3
> result.should =~ /regex/
> 
> Personally, I prefer should_be and should_match in these cases, as I
> think they read better. Anyone else have opinions about that?

I agree.  I don't mind should =~ so much (though I probably wouldn't use 
it myself), but "should ==" reads "should_equal" to me, which is 
different than "should_be".

> This patch also supports using methods that are not formatted like
> predicates but act like them:
> 
> def whatever
>   true
> end
> 
> subject.should_be_whatever
> 
> I really object to this on philosophical grounds.

This is so simple that I don't understand it... how/why would I use that 
in a real spec?

Jay




More information about the Rspec-devel mailing list