[rspec-users] do I use mocking (vs fixtures) for methods that produce results based on non-trivial SQL queries

Pat Maddox pergesu at gmail.com
Fri Sep 5 10:40:37 EDT 2008

On Fri, Sep 5, 2008 at 7:23 AM, Mark Wilden <mark at mwilden.com> wrote:
> On Fri, Sep 5, 2008 at 7:08 AM, Greg Hauptmann
> <greg.hauptmann.ruby at gmail.com> wrote:
>> Hi,
>> In cases where I have model methods that are generating data based on
>> non-trivial SQL queries to a database (e.g. to pull together data
>> required to plot an appropriate graph), does this really require a
>> traditional fixture (i.e. pre-canned test data) as opposed to use of
>> mocks?
> I don't see how you could use mocks to test SQL. You need rows in the
> database to do this. I personally do not use fixtures because my model specs
> usually don't use a "typical" data set. I'll create my own data set for each
> type of spec, often using an object mother to create the valid network of
> objects.


More information about the rspec-users mailing list