Permalink
Browse files

Fixed specs

  • Loading branch information...
1 parent 8bc3e5f commit 47c8096fa37e2adad7251569ea0695ed2713036b @fabien committed Sep 19, 2008
Showing with 14 additions and 12 deletions.
  1. +1 −1 bin/minigem
  2. +5 −7 lib/minigems.rb
  3. +8 −4 spec/minigems_spec.rb
View
@@ -72,7 +72,7 @@ elsif ARGV[0] == 'revert'
elsif ARGV[0] == 'install' || ARGV[0] == 'update'
# Install or update a rubygem and prepare it for minigems.
command = ARGV.shift.to_sym # skip command argument
- ensure_in_load_path!
+ ensure_in_load_path!(ARGV.empty?)
# Remove any gems that have been specified.
unless ARGV.empty?
cmd = Gem::GemRunner.new.run_command(command, ARGV)
View
@@ -114,20 +114,18 @@ def self.activate(gem, *version_requirements)
elsif already_loaded
return false
end
-
+
# Keep track of loaded gems - by name instead of full specs (memory!)
self.loaded_gems[gem_spec.name] = gem_spec.full_name
# Load dependent gems first
gem_spec.runtime_dependencies.each { |dep_gem| activate(dep_gem) }
-
- # Add gem bindir path to $LOAD_PATH
- unless gem_spec.executables.empty?
- $LOAD_PATH.unshift File.join(gem_spec.full_gem_path, gem_spec.bindir)
- end
+
+ # bin directory must come before library directories
+ gem_spec.require_paths.unshift(gem_spec.bindir) if gem_spec.bindir
# Add gem require paths to $LOAD_PATH
- gem_spec.require_paths.each do |require_path|
+ gem_spec.require_paths.reverse.each do |require_path|
$LOAD_PATH.unshift File.join(gem_spec.full_gem_path, require_path)
end
return true
View
@@ -51,24 +51,28 @@
gem_bin_path = File.join(@gem_dir, "gems", "gem_with_lib-0.0.2", "bin")
$LOAD_PATH.should_not include(gem_lib_path)
gem("gem_with_lib").should be_true
- $LOAD_PATH.first.should == gem_lib_path
- $LOAD_PATH.should include(gem_bin_path)
+ $LOAD_PATH.first.should == gem_bin_path
+ $LOAD_PATH.should include(gem_lib_path)
$LOAD_PATH.select { |path| path == gem_lib_path }.length.should == 1
lambda { GemWithLib::Awesome }.should raise_error(NameError)
end
it "uses 'gem' to setup additional load path entries (for a specific gem version)" do
gem_lib_path = File.join(@gem_dir, "gems", "gem_with_lib-0.0.1", "lib")
+ gem_bin_path = File.join(@gem_dir, "gems", "gem_with_lib-0.0.1", "bin")
$LOAD_PATH.should_not include(gem_lib_path)
gem("gem_with_lib", "0.0.1").should be_true
- $LOAD_PATH.first.should == gem_lib_path
+ $LOAD_PATH.first.should == gem_bin_path
+ $LOAD_PATH.should include(gem_lib_path)
end
it "uses 'gem' to setup additional load path entries (for a gem version requirement)" do
gem_lib_path = File.join(@gem_dir, "gems", "gem_with_lib-0.0.2", "lib")
+ gem_bin_path = File.join(@gem_dir, "gems", "gem_with_lib-0.0.2", "bin")
$LOAD_PATH.should_not include(gem_lib_path)
gem("gem_with_lib", ">0.0.1").should be_true
- $LOAD_PATH.first.should == gem_lib_path
+ $LOAD_PATH.first.should == gem_bin_path
+ $LOAD_PATH.should include(gem_lib_path)
end
it "correctly requires a file from the load path" do

0 comments on commit 47c8096

Please sign in to comment.