summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-08-27 04:41:34 +0000
committerColby Swandale <me@colby.fyi>2018-09-14 22:26:18 +1000
commiteb0f3b30f508ecb3416f1122813f96f5112ac5b4 (patch)
tree4449c907965aa1604c2fcfed70f2f06e771b26a0
parent2c5212fc70d38e5a01ed1114656bd014d02eafa9 (diff)
downloadbundler-eb0f3b30f508ecb3416f1122813f96f5112ac5b4.tar.gz
Auto merge of #6669 - ChrisBr:fix_dep_proxy, r=segiddins
Fix DepProxy == method ### What was the end-user problem that led to this PR? After implementing a new hash table strategy in JRuby, bundle is broken for JRuby. The problem is caused that the ``==`` method in bundler does not check the class of the ``other`` object. This causes problems now when calling ``==`` on object other than DepProxy or nil. jruby/jruby#5280 travis-ci/travis-ci#9994 ### What was your diagnosis of the problem? The code crashes for anything other than DepProxy class or nil. ### What is your fix for the problem, implemented in this PR? Checking now also that other class is the same as self. (cherry picked from commit 1856133136a5ef75a8d42fb45b3ea7dddcad2f30)
-rw-r--r--lib/bundler/dep_proxy.rb4
-rw-r--r--spec/bundler/dep_proxy_spec.rb22
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/bundler/dep_proxy.rb b/lib/bundler/dep_proxy.rb
index 7a9423b14a..6c32179ac1 100644
--- a/lib/bundler/dep_proxy.rb
+++ b/lib/bundler/dep_proxy.rb
@@ -10,11 +10,11 @@ module Bundler
end
def hash
- @hash ||= dep.hash
+ @hash ||= [dep, __platform].hash
end
def ==(other)
- return if other.nil?
+ return false if other.class != self.class
dep == other.dep && __platform == other.__platform
end
diff --git a/spec/bundler/dep_proxy_spec.rb b/spec/bundler/dep_proxy_spec.rb
new file mode 100644
index 0000000000..0f8d6b1076
--- /dev/null
+++ b/spec/bundler/dep_proxy_spec.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+RSpec.describe Bundler::DepProxy do
+ let(:dep) { Bundler::Dependency.new("rake", ">= 0") }
+ subject { described_class.new(dep, Gem::Platform::RUBY) }
+ let(:same) { subject }
+ let(:other) { subject.dup }
+ let(:different) { described_class.new(dep, Gem::Platform::JAVA) }
+
+ describe "#eql?" do
+ it { expect(subject.eql?(same)).to be true }
+ it { expect(subject.eql?(other)).to be true }
+ it { expect(subject.eql?(different)).to be false }
+ it { expect(subject.eql?(nil)).to be false }
+ it { expect(subject.eql?("foobar")).to be false }
+ end
+
+ describe "#hash" do
+ it { expect(subject.hash).to eq(same.hash) }
+ it { expect(subject.hash).to eq(other.hash) }
+ end
+end