summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-08-27 04:41:34 +0000
committerThe Bundler Bot <bot@bundler.io>2018-08-27 04:41:34 +0000
commit1856133136a5ef75a8d42fb45b3ea7dddcad2f30 (patch)
tree2798ce44b9e8ecaca7873dda385697660dbef30a
parent668c06102dbf9843c19c3524fd43c0731d451ffa (diff)
parentce92868fcab4a532174d6cebeb9c9d56e6c79bfb (diff)
downloadbundler-1856133136a5ef75a8d42fb45b3ea7dddcad2f30.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.
-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