[rspec-users] Should change not comparing arrays how I expected

Ashley Moran ashley.moran at patchspace.co.uk
Sun Sep 28 18:09:42 EDT 2008


On Sep 28, 2008, at 7:52 pm, David Chelimsky wrote:

> What you're proposing could be resolved with an argument constraint
> that's been discussed in some other threads on this list - something
> like:
>
>  lambda {...}.should change{...}.to(array_consisting_of(...))
>
> I'd prefer this as it lets us keep the single matcher, but allows us
> to make it more flexible by adding different constraints. We already
> have hash_including. This would expand that sort of capability.
>
> WDYT?



On the basis that my code isn't a Rails app*, but I'd still like this  
fix, I vote +1 for "array_consisting_of" (or something).

How about...
   lambda {...}.should change{...}.to(collection_equivalent_to(...))
?

Bit long winded but I think it expresses the intent?  (Correct me if  
not...)

As for change vs change_contents_of, I vote for keeping the one  
matcher.  I don't think I should be expected to know when an object  
that replies to ==([]) is not an array.

Or an H R Giger alien for that matter...

Cheers
Ashley



* Ironically in my attempt to escape Rails, I have, in the same day,  
both been bitten by an ORM that behaves like ActiveRecord, and a  
different gem that loads ActiveSupport and borks 'require' when I run  
my specs.  =(

-- 
http://www.patchspace.co.uk/
http://aviewfromafar.net/



More information about the rspec-users mailing list