diff options
author | Christian Bruckmayer <cbruckmayer@suse.com> | 2018-08-22 22:29:12 +0200 |
---|---|---|
committer | Christian Bruckmayer <cbruckmayer@suse.com> | 2018-08-23 10:17:16 +0200 |
commit | ce92868fcab4a532174d6cebeb9c9d56e6c79bfb (patch) | |
tree | cf9fa897217b04c69ef5d71d4b431db1318bccd3 | |
parent | fd43f1135ccd239667ea03fb17fa6334610e9fbe (diff) | |
download | bundler-ce92868fcab4a532174d6cebeb9c9d56e6c79bfb.tar.gz |
Fix DepProxy#hash calculation
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
-rw-r--r-- | lib/bundler/dep_proxy.rb | 2 | ||||
-rw-r--r-- | spec/bundler/dep_proxy_spec.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/bundler/dep_proxy.rb b/lib/bundler/dep_proxy.rb index 77db9ebfb7..6c32179ac1 100644 --- a/lib/bundler/dep_proxy.rb +++ b/lib/bundler/dep_proxy.rb @@ -10,7 +10,7 @@ module Bundler end def hash - @hash ||= dep.hash + @hash ||= [dep, __platform].hash end def ==(other) diff --git a/spec/bundler/dep_proxy_spec.rb b/spec/bundler/dep_proxy_spec.rb index 16d2210b75..0f8d6b1076 100644 --- a/spec/bundler/dep_proxy_spec.rb +++ b/spec/bundler/dep_proxy_spec.rb @@ -14,4 +14,9 @@ RSpec.describe Bundler::DepProxy do 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 |