Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

deprecation of Gem::LoadError#version_requirement

  • Loading branch information...
commit b77b83f3b2dfee3fa5776d46935d734c68804c50 1 parent cde349c
@hone hone authored
View
6 lib/bundler/runtime.rb
@@ -23,7 +23,11 @@ def setup(*groups)
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
"but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec."
e.name = spec.name
- e.version_requirement = Gem::Requirement.new(spec.version.to_s)
+ if e.respond_to?(:requirement=)
+ e.requirement = Gem::Requirement.new(spec.version.to_s)
+ else
+ e.version_requirement = Gem::Requirement.new(spec.version.to_s)
+ end
raise e
end
View
13 lib/bundler/shared_helpers.rb
@@ -96,15 +96,24 @@ def cripple_rubygems(specs)
spec = specs.find { |s| s.name == dep.name }
if spec.nil?
+
e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
e.name = dep.name
- e.version_requirement = dep.requirement
+ if e.respond_to?(:requirement=)
+ e.requirement = dep.requirement
+ else
+ e.version_requirement = dep.requirement
+ end
raise e
elsif dep !~ spec
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
"Make sure all dependencies are added to Gemfile."
e.name = dep.name
- e.version_requirement = dep.requirement
+ if e.respond_to?(:requirement=)
+ e.requirement = dep.requirement
+ else
+ e.version_requirement = dep.requirement
+ end
raise e
end
View
51 spec/runtime/setup_spec.rb
@@ -129,6 +129,19 @@
out.should == "WIN"
end
+ it "version_requirement is now deprecated in rubygems 1.4.0+ when gem is missing" do
+ run <<-R, :expect_err => true
+ begin
+ gem "activesupport"
+ puts "FAIL"
+ rescue LoadError
+ puts "WIN"
+ end
+ R
+
+ err.should be_empty
+ end
+
it "replaces #gem but raises when the version is wrong" do
run <<-R
begin
@@ -141,6 +154,19 @@
out.should == "WIN"
end
+
+ it "version_requirement is now deprecated in rubygesm 1.4.0+ when the version is wrong when the version is wrong" do
+ run <<-R, :expect_err => true
+ begin
+ gem "rack", "1.0.0"
+ puts "FAIL"
+ rescue LoadError
+ puts "WIN"
+ end
+ R
+
+ err.should be_empty
+ end
end
describe "by hiding system gems" do
@@ -348,6 +374,31 @@
out.should == "You have already activated thin 1.1, but your Gemfile requires thin 1.0. Consider using bundle exec."
end
+
+ it "version_requirement is now deprecated in rubygems 1.4.0+" do
+ system_gems "thin-1.0", "rack-1.0.0"
+ build_gem "thin", "1.1", :to_system => true do |s|
+ s.add_dependency "rack"
+ end
+
+ gemfile <<-G
+ gem "thin", "1.0"
+ G
+
+ ruby <<-R, :expect_err => true
+ require 'rubygems'
+ gem "thin"
+ require 'bundler'
+ begin
+ Bundler.setup
+ puts "FAIL"
+ rescue Gem::LoadError => e
+ puts e.message
+ end
+ R
+
+ err.should be_empty
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.