[rspec-users] Using Predicates to look at an array..

Nick Sieger nicksieger at gmail.com
Thu Oct 4 12:46:10 EDT 2007

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.


More information about the rspec-users mailing list