Defensive check for Checksum == nil
Protects against NoMethodError when checking a Checksum instance with a bad 'other'
This commit is contained in:
parent
2ec684a123
commit
58dd8f4770
@ -13,6 +13,6 @@ class Checksum
|
||||
delegate [:empty?, :to_s] => :@hexdigest
|
||||
|
||||
def ==(other)
|
||||
hash_type == other.hash_type && hexdigest == other.hexdigest
|
||||
hash_type == other&.hash_type && hexdigest == other.hexdigest
|
||||
end
|
||||
end
|
||||
|
||||
@ -15,5 +15,6 @@ describe Checksum do
|
||||
it { is_expected.to eq(other) }
|
||||
it { is_expected.not_to eq(other_reversed) }
|
||||
it { is_expected.not_to eq(other_sha1) }
|
||||
it { is_expected.not_to eq(nil) }
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user