Skip to content

Commit 5286b7c

Browse files
committed
Land rapid7#3566, ducktype better
2 parents 6c1a3f4 + 064d624 commit 5286b7c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/metasploit/framework/credential.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def to_s
7878
end
7979

8080
def ==(other)
81-
other.public == self.public && other.private == self.private && other.realm == self.realm
81+
other.respond_to?(:public) && other.public == self.public &&
82+
other.respond_to?(:private) && other.private == self.private &&
83+
other.respond_to?(:realm) && other.realm == self.realm
8284
end
8385

8486
def to_credential

spec/lib/metasploit/framework/credential_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@
132132
expect(other).not_to eq(cred_detail)
133133
end
134134
end
135-
135+
context "when comparing to a different object" do
136+
let(:other) {'a string'}
137+
specify do
138+
expect(other).not_to eq(cred_detail)
139+
end
140+
end
136141
end
137142
end

0 commit comments

Comments
 (0)