[rspec-users] Using Predicates to look at an array..
dchelimsky at gmail.com
Thu Oct 4 13:32:57 EDT 2007
On 10/4/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
> On Oct 4, 2007, at 12:46 PM, Nick Sieger wrote:
> > On 10/4/07, Eric Pugh <epugh at opensourceconnections.com> wrote:
> >> Hi all,
> >> I have an array of shipping_type's being returned, and I want to see
> >> what is in there. In the past I have done:
> >> shipping_type.include?(Cart::SHIPPING_TYPE_REGULAR).should
> >> be_true
> >> This works, but looks really ugly.. It just doesn't roll of the
> >> tongue very well. I then looked up the use of Predicates, which I
> >> had been using, but hadn't realized:
> >> shipping_type.should be_include(Cart::SHIPPING_TYPE_REGULAR)
> > You were close on this one, it should just be
> > shipping_type.should include(Cart::SHIPPING_TYPE_REGULAR)
> > It's a special predicate just for working with arrays.
> Isn't it a general predicate for all foo? (boolean) methods?
> class Object
> def foo?
> Object.new.should be_foo
> Doesn't that work, as well?
Sure it does, but be_include sounds icky. That's the point of this
thread, I believe.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users