[rspec-users] Newbie questions - Best practice for loading local db data and model tests? (factory_girl , debugging ?)

Rick R rickcr at gmail.com
Tue Nov 23 15:19:36 EST 2010

I'm pretty much a newbie with Rails and RSpec. I'm trying to follow best
practices as I start to work on my own Rails side project.

I'm using: rspec 2.1.0 / Rails 3.0.1 / ruby 1.9.2

1) Currently I have a Rake task that I run that populates the local sqlite
db by using Rails models directly. Is this an ok approach to load simple
local data so your app is in a state for using it while developing? eg
    10.times do |x|
        u = User.new(...)

2) Is there a way I can just have my rspec tests run off the local sqlite db
populated from my rake task? or is this a bad practice? I currently have
messed around some using factory_girl factories and I can generate
everything using the factories and use them in my rspec model tests, but
this seems like I'm doing double the  work - I'm loading things in my rake
file and then again similar things are loaded with my factories? - maybe the
solution is to leverage the factory_girl factories to also populate my local
db with a rake task?
What is the preferred approach for setting this kind of stuff up so your
application has local data for working with and also for testing your

3) Is there any way to use log/put statements to help in debugging within an
rspec test so that I can run a single test and see what's going on directly
in the console?

(I'm finding it difficult to find a lot of this documentation in one place.
If all of the above kind of questions are easily covered in David's
pragmatic rspec book, then I'll just go get the electronic version.)


Rick R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101123/37bbcb3f/attachment.html>

More information about the rspec-users mailing list