niedziela, 26 lutego 2012

How to proper test scopes (named scopes)

I just read few posts about "how to test named scopes". I'm asking - why should I use FactoryGirl and create tons of unnecessary objects just to test `order(:position).first`?!

How not to do this

We've just created .. let's count .. 5 objects and made 2 unnecessary db queries

How to do this

It's useless to test Rails (it's really proper tested). We need to spec messages that goes between objects and given parameters.

Brak komentarzy:

Prześlij komentarz