Created
April 21, 2010 23:36
-
-
Save purp/374591 to your computer and use it in GitHub Desktop.
Patch to help RSpec.tmbundle properly find vendorized rspec in modern Rails
This file contains hidden or 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
diff --git a/Support/lib/spec/mate.rb b/Support/lib/spec/mate.rb | |
index 6d0ce89..b634303 100644 | |
--- a/Support/lib/spec/mate.rb | |
+++ b/Support/lib/spec/mate.rb | |
@@ -1,18 +1,18 @@ | |
# This is based on Florian Weber's TDDMate | |
require 'rubygems' | |
+# Load spec/autorun | |
ENV['TM_PROJECT_DIRECTORY'] ||= File.dirname(ENV['TM_FILEPATH']) | |
-rspec_rails_plugin = File.join(ENV['TM_PROJECT_DIRECTORY'],'vendor','plugins','rspec','lib') | |
+rspec_locs = Dir.glob(File.join(ENV['TM_PROJECT_DIRECTORY'],'vendor','{plugins,gems}','rspec{,-[0-9]*}', 'lib')) | |
+rspec_locs << File.join(ENV['TM_RSPEC_HOME'], 'lib') if ENV['TM_RSPEC_HOME'] | |
+rspec_root = rspec_locs.reject { |rr| !File.exists?(File.join(rr, %w(spec autorun.rb))) }.first | |
-if File.directory?(rspec_rails_plugin) | |
- $LOAD_PATH.unshift(rspec_rails_plugin) | |
+if rspec_root | |
+ $LOAD_PATH.unshift(rspec_root) | |
elsif ENV['TM_RSPEC_HOME'] | |
- rspec_lib = File.join(ENV['TM_RSPEC_HOME'], 'lib') | |
- unless File.directory?(rspec_lib) | |
- raise "TM_RSPEC_HOME points to a bad location: #{ENV['TM_RSPEC_HOME']}" | |
- end | |
- $LOAD_PATH.unshift(rspec_lib) | |
+ raise "TM_RSPEC_HOME points to a bad location: #{ENV['TM_RSPEC_HOME']}" unless File.directory?(File.join(ENV['TM_RSPEC_HOME'], 'lib')) | |
end | |
+ | |
require 'spec/autorun' | |
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/..') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This patches the mate.rb script that comes with RSpec.tmbundle to find the rspec gem if it's been vendored in vendor/plugins, vendor/gems, or specified using TM_RSPEC_HOME. Should work all the way back to rspec-1.1.2