summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Bruckmayer <cbruckmayer@suse.com>2018-08-22 09:25:40 +0200
committerChristian Bruckmayer <cbruckmayer@suse.com>2018-08-23 10:16:06 +0200
commitfd43f1135ccd239667ea03fb17fa6334610e9fbe (patch)
tree8891a059ac29e2c85a58a8a4ab2736a8f1ffc2e7
parent72f27b0dd8c92159bf769a531cfa97672bf4c1e4 (diff)
downloadbundler-fd43f1135ccd239667ea03fb17fa6334610e9fbe.tar.gz
Fix DepProxy#== undefind method error
DepProxy#== crashed with an undefind method error for anything other than a DepProxy class or nil as parameter. This was caused that it was assumed only DepProxy instances or nil can get passed as parameter. This commit implements checking the class as well and returns false if the classes are not the same. Fixes jruby/jruby#5280 travis-ci/travis-ci#9994
-rw-r--r--lib/bundler/dep_proxy.rb2
-rw-r--r--spec/bundler/dep_proxy_spec.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/bundler/dep_proxy.rb b/lib/bundler/dep_proxy.rb
index 7a9423b14a..77db9ebfb7 100644
--- a/lib/bundler/dep_proxy.rb
+++ b/lib/bundler/dep_proxy.rb
@@ -14,7 +14,7 @@ module Bundler
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..16d2210b75
--- /dev/null
+++ b/spec/bundler/dep_proxy_spec.rb
@@ -0,0 +1,17 @@
+# 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
+end