Skip to content

Instantly share code, notes, and snippets.

@joakimk
Created January 26, 2012 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joakimk/1682163 to your computer and use it in GitHub Desktop.
Save joakimk/1682163 to your computer and use it in GitHub Desktop.
Load path optimizations to use gems in sub-second test suites
def add_load_path(path)
full_path = "#{ENV["HOME"]}/.rvm/gems/ruby-version@project/#{path}"
raise("load path missing: #{full_path}") unless File.exists?(full_path)
$: << full_path
end
rails_version = File.readlines(File.join(File.dirname(__FILE__), "../../Gemfile")).
find { |line| line.include?("'rails'") }.split.last.gsub("'",'')
add_load_path "bundler/gems/draper-version/lib"
add_load_path "gems/activesupport-#{rails_version}/lib"
# require 'active_support/core_ext'
# time to load with load path fix: 200ms, without 1200ms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment