On 12 Nov 2008, at 17:43, Mark Wilden wrote:
On Wed, Nov 12, 2008 at 7:55 AM, Matt Wynne <[EMAIL PROTECTED]> wrote:
How about something more like

   Given there are two items in a list: "Zulu and Abba"
   And I have sorted the list alphabetically
   Then "Abba" should appear before "Zulu"

Then /"(.*)" should appear before "(.*)"/ do |first_example, second_example|
   response.body.should =~ /#{first_example}.*#{second_example}/
end

The trouble with that is that you still have a 50-50 chance that your code is broken. :) Testing sorting is always problematic. Given a particular data set, other factors may be producing the "right" order (sorting on a different attribute, randomization). I usually use three items, and realize that it's not definitive.

Sure, but balance it with another scenario that sorts it the other way, and you'd have to be pretty unlucky to get a false positive from both at the same time.

:)

cheers,
Matt

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to