[rspec-users] Cucumber feature checking sort order of list
Mark Wilden
mark at mwilden.com
Wed Nov 12 12:43:47 EST 2008
On Wed, Nov 12, 2008 at 7:55 AM, Matt Wynne <matt at mattwynne.net> 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.
///ark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081112/f65d6793/attachment.html>
More information about the rspec-users
mailing list