Faster Specs without Loading Rails
If you’re writing unit specs in a Rails project and you don’t need Rails and all of its machinery to load in your spec while you’re iterating (for instance, because Rails takes 15+ seconds to load), you can just require the class you’re concerned with.
#require 'spec_helper' require 'rubygems' require 'active_support/all' require File.join(*[File.dirname(__FILE__)] + %w[.. lib services mything])
I use this when I’m writing specs for an isolated service object or adapter class, for instance, and I need to re-run the specs constantly. When I’m done I can just remove the 3 extra requires and go back to requiring spec_helper.
It’s not a long-term fix or anything—just a quick hack to get specs running faster when you’re iterating quickly on an isolated piece of code.
11 Notes/ Hide
-
corporation90up liked this
-
developed6ok liked this
-
seasonalyp9 liked this
-
really256gp liked this
-
globalspin liked this
-
iampedantic posted this