On Fri, Apr 8, 2011 at 02:52, Stefan Kanev <stefan.ka...@gmail.com> wrote:
> Occasionally, I write specs that verify the order in which some ActiveRecord > objects are returned. For example, in a toy project I do: > > Reply.stub :per_page => 2 > topic.replies_on_page(1).should == [second, first] > > The spec out quickly get unwieldy when it fails: <snip /> If you only want to check the identity of the Reply objects, then shouldn't you only check the identity of the Reply objects? topic.replies_on_page(1).collect(&:id).should == [second, first].collect(&:id) Now introduce a custom matcher and off you go. topic.replies_on_page(1).should match_models([second, first]), maybe? -- J. B. (Joe) Rainsberger :: http://www.jbrains.ca :: http://blog.thecodewhisperer.com Diaspar Software Services :: http://www.diasparsoftware.com Author, JUnit Recipes 2005 Gordon Pask Award for contribution to Agile practice :: Agile 2010: Learn. Practice. Explore. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users