redding/ardb — pull request #58 by jcredding (2014-01-08 21:16:24+00:00)
Title: Expand `RelationSpy` with more query, spawn and finder methods

This adds more of ActiveRecord's query, spawn and finder methods.
This makes the spy more featureful and useful for testing. This
also organizes the class, adding comments for what ActiveRecord
class the methods come from. It also organizes the tests to use
better use cases and more explicit tests. Before the tests were
just a "sea of shoulds" and it was difficult to find where each
method was being tested.

This also expands the `merge` to perform more "merge" like
behavior. If a relation spy is passed to the `merge`, it will
add it's applied expressions. It still has it's old behavior
if a non relation spy is passed to the `merge` method.

This also removes `order_values` and `reverse_order_value` from
the spy. This was a short sighted addition as these require
double-managing the values and the applied expressions. Furthermore,
these methods seem to be intended as "private" or for internal
use only, as they require specific knowledge of how to set them
correctly. I'd rather not have the spy worry about managing both
ActiveRecord's hash of values and the spies list of applied
expressions.

@kellyredding - Sorry for all the back-and-forth on the spy. I blindly went ahead with #57 and rolled a version, and though it was a proper spy, I don't think it's advisable to get into worrying about the "values" methods that ActiveRecord does. It's a lot of extra aggro for not much gain. I'd rather re-work the whole spy to only use "values" than manage both.

Anyway, I started this while I was trying to handle the find method on MR's read model. I had it mostly implemented and then decided to not even use it. I thought these changes were useful (particularly the `find`, `first` and `last`). I also tried to add any query methods we've used in apps.