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

Eric Pugh epugh at opensourceconnections.com
Thu Oct 4 12:41:39 EDT 2007


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)

This works, however the syntac of be_include looks very odd...   Is  
there any way to do:

    shipping_type.should_include(Cart::SHIPPING_TYPE_REGULAR)

How are other folks looking at the contents of an Array?  Am I going  
around bassackwards on this?

Eric


-----------------------------------------------------
Eric Pugh | Principal | OpenSource Connections, LLC | 434.466.1467 |  
http://www.opensourceconnections.com





More information about the rspec-users mailing list