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

Greg Hauptmann greg.hauptmann.ruby at gmail.com
Fri Sep 5 10:08:37 EDT 2008


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?

That is, the bulk of the method is really the SQL that is pull back
(with multiple joins / selects etc) the data required.  Testing to
some extent should be focused around testing the SQL is producing what
it should.   How would one use rspec / mocha to solve this?  i.e. in a
normal testing sense you may need 5 to 10 rows before you can feel
comfortable the SQL code is doing what it should..

Tks


More information about the rspec-users mailing list