[rspec-users] spec'ing the :conditions argument of a find

Matt Wynne matt at mattwynne.net
Fri Oct 31 03:49:25 EDT 2008


On 30 Oct 2008, at 20:11, Pat Maddox wrote:
> Matt Wynne <matt at mattwynne.net> writes:
>
>> On 30 Oct 2008, at 15:58, Zach Dennis wrote:
>>> I know the above example breaks the one assertion per test guideline
>>> people strive to adhere to, but I think it is ok.  If there are more
>>> examples that should be used to make sure find_thingy works then I'd
>>> break out a separate describe block and have multiple 'it' examples,
>>
>> It also goes to the database, which will make it a slow unit test. I
>> personally do pretty much the same thing myself mostly when working
>> with ActiveRecord, but it doesn't mean I'm comfortable with it. (And
>> it also doesn't mean our unit test suite is anything other than
>> shamefully slow)
>>
>> I did experiment with a QueryApapter for this purpose which has  
>> worked
>> out quite well for us. You end up with code like this in the
>> Controller:
>
> Scott is working on a SQL parser which would let you write tests that
> "hit" the db but keep everything in memory and fast.  Might be worth
> checking out for you.

Sounds interesting. I'd still like to see us have a proper ORM for  
ruby that lets us play with POROs 90% of the time, and just have a  
separate suite of tests for the database-object mappings that we run  
when necessary.

cheers,
Matt


More information about the rspec-users mailing list