Reputation: 775
I want to speed up my model tests. After seeing this http://iain.nl/testing-activerecord-in-isolation, I thought it could be achieved if i can only require the active_record rather than loading the spec_helper.rb, which loads the whole Rails stack for every test file. I am using rspec-rails with factory_girl. But so far its not working for me. Every time i run a single file the whole migrations are getting run, which is not acceptable.And before the whole migrations run i am getting some errors. Anybody have a better idea?
Upvotes: 1
Views: 417
Reputation: 395
If you're looking to speed up your tests by not having to reload the Rails environment each time, you should look into using Spork, Guard, and Guard::Spork. Spork allows you to run a separate, "clean" test server, while Guard enables you to keep it running in the background by observing your files for changes.
Spork: https://github.com/sporkrb/spork
Guard::Spork: https://github.com/guard/guard-spork
The ever-helpful Railscast: http://railscasts.com/episodes/285-spork
Upvotes: 1
Reputation: 3260
I did something similar recently.
See if this helps: http://technorattle.wordpress.com/2013/01/10/activerecord-outside-rails/
Upvotes: 1