[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 17:17:53 EDT 2008


On Fri, Sep 5, 2008 at 12:39 PM, Greg Hauptmann <
greg.hauptmann.ruby at gmail.com> wrote:

>    Did you just mean that at the start of a test you create test data
> in the database programmatically, as opposed to hard wiring it in a
> fixture?
>

Yes, that's right. Our code has a lot of support for creating networks of
objects (e.g., you want to test a video, which requires some assets, a
company, a site, maybe a reseller). Or you just mock out the other objects.
The point is that you can get just the object(s) you want without the
constraints of "one size fits all" data.

In fact, fixtures can get in the way, which is why you'll see
Video.delete_all in a lot of our before(:each)'s (often accompanied by
acerbic comments about "fixture bullshit.") As I've mentioned before, It's
been really great working with code from an RSpec master. The dividing line
between his code and that of the other developers is fairly clear-cut. :)

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


More information about the rspec-users mailing list