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

Mark Wilden mark at mwilden.com
Fri Sep 5 10:23:59 EDT 2008

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080905/ab9394dc/attachment.html>

More information about the rspec-users mailing list