I am Pedantic.

  • Archive
  • RSS
  • Talk to me

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.

    • #code
    • #tools
  • 3 months ago
  • 11
  • Permalink
  • Share

11 Notes/ Hide

  1. corporation90up liked this
  2. developed6ok liked this
  3. seasonalyp9 liked this
  4. really256gp liked this
  5. globalspin liked this
  6. iampedantic posted this
← Previous • Next →

Pedantry, software, freedom, beauty and minimalism.

by Brad Fults

Brad on the Internet

  • h3h on Dribbble
  • @h3h on Twitter
  • Facebook Profile
  • h3h on Flickr
  • h3h on Last.fm
  • h3h on Gowalla
  • h3h on github
  • RSS
  • Random
  • Archive
  • Talk to me
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr