Created
January 26, 2012 10:34
-
-
Save joakimk/1682163 to your computer and use it in GitHub Desktop.
Load path optimizations to use gems in sub-second test suites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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