Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Fix DepProxy#hash calculation
Browse files Browse the repository at this point in the history
According to the official Ruby documentation, "the eql? method returns true if obj and other
refer to the same hash key." This was not the case as the hash key of a DepProxy instance was
only calculated based on the dep object but in the eql? method dep and platform attributes were
computed. This caused that equal objects returned different hash keys.

https://ruby-doc.org/core-2.5.1/Object.html#method-i-eql-3F
  • Loading branch information
ChrisBr committed Aug 22, 2018
1 parent b939e3c commit 9e0578e
Show file tree
Hide file tree
Showing 2 changed files with 6 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 @@ -10,7 +10,7 @@ def initialize(dep, platform)
end

def hash
@hash ||= dep.hash
@hash ||= [dep, __platform].hash
end

def ==(other)
Expand Down
5 changes: 5 additions & 0 deletions spec/bundler/dep_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
it { expect(subject == nil).to be false }
it { expect(subject == 'foobar').to be false }
end

describe "#hash" do
it { expect(subject.hash).to eq(subject.hash) }
it { expect(subject.hash).to eq(other.hash) }
end
end

0 comments on commit 9e0578e

Please sign in to comment.