I want to speed up my model tests. After seeing this
Testing ActiveRecord in isolation - iain.nl, 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.
Don't run rspec command? Use Guard and keep on developing letting it
tell you when tests fail and pass rather than caring about the 1
second, it's inefficient to stop and run rspec when you can let Guard
do it and backtrack, because at least then you didn't waste the
seconds going to the terminal, typing the command, waiting and then
crying (not that you cried but I would - actually, I would probably
flip a table while crying like a baby because I would be mad I not
only had to wait but that a test failed.)
You can also use Guard + Spork or just Spork which will preload your
entire Rails app switching up changed pieces making your tests run
faster, but note that Spork breaks SimpleCov (by design, probably not
by intention as kinda implied by the massive ticket discussion -- at
least to me.) To me losing SimpleCov was a big no-no so I developed
the aforementioned attitude where I develop and keep on developing
backtracking as I need to (because Guard says a test failed) rather
than waiting and fixing and wasting time.