Skip to content

Commit

Permalink
Fix DepProxy#== undefind method error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ChrisBr committed Aug 23, 2018
1 parent 72f27b0 commit fd43f11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/dep_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def hash
end

def ==(other)
return if other.nil?
return false if other.class != self.class
dep == other.dep && __platform == other.__platform
end

Expand Down
17 changes: 17 additions & 0 deletions spec/bundler/dep_proxy_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fd43f11

Please sign in to comment.