Defensive check for Checksum == nil

Protects against NoMethodError when checking a Checksum instance with a bad 'other'
This commit is contained in:
Alexander Mancevice 2018-03-24 09:04:51 -04:00
parent 2ec684a123
commit 58dd8f4770
2 changed files with 2 additions and 1 deletions

View File

@ -13,6 +13,6 @@ class Checksum
delegate [:empty?, :to_s] => :@hexdigest delegate [:empty?, :to_s] => :@hexdigest
def ==(other) def ==(other)
hash_type == other.hash_type && hexdigest == other.hexdigest hash_type == other&.hash_type && hexdigest == other.hexdigest
end end
end end

View File

@ -15,5 +15,6 @@ describe Checksum do
it { is_expected.to eq(other) } it { is_expected.to eq(other) }
it { is_expected.not_to eq(other_reversed) } it { is_expected.not_to eq(other_reversed) }
it { is_expected.not_to eq(other_sha1) } it { is_expected.not_to eq(other_sha1) }
it { is_expected.not_to eq(nil) }
end end
end end