> I have a named scope that sets a sort order.  In my unit test I can
> run the query on a set of records (using Factory or fixtures) and
> check the sort order is correct.  I believe though that a find without
> an explicit sort order may return the records in any order, so how can
> I be sure that it is not just accidental that they are in the correct
> order?

Colin:

I would argue that it's unimportant -- even at the unit-level -- *how*
the test is passing. If every time you run the test it passes, then
the code does what you specify it does. When there's a problem,
identify the bug and write a new unit, integration, or functional test
that eliminates the unexpected behavior, then make that test pass.

I might also argue that it's not up to you to test ActiveRecord. You
might assert that your named scope is passing the correct sorting
parameters to ActiveRecord; at that point, it's up to ActiveRecord to
hold up its end of the bargain.

What do you think of that?

Andrew M. Kasper

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to