File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def []=(key, value)
38
38
end
39
39
40
40
def ==( other )
41
- self [ :kid ] == other [ :kid ]
41
+ other . is_a? ( :: JWT :: JWK :: KeyBase ) && self [ :kid ] == other [ :kid ]
42
42
end
43
43
44
44
alias eql? ==
Original file line number Diff line number Diff line change 82
82
end
83
83
end
84
84
end
85
+
86
+ describe '#==' do
87
+ it 'is equal to itself' do
88
+ other = jwk
89
+ expect ( jwk == other ) . to eq true
90
+ end
91
+
92
+ it 'is equal to a clone of itself' do
93
+ other = jwk . clone
94
+ expect ( jwk == other ) . to eq true
95
+ end
96
+
97
+ it 'is not equal to nil' do
98
+ other = nil
99
+ expect ( jwk == other ) . to eq false
100
+ end
101
+
102
+ it 'is not equal to boolean true' do
103
+ other = true
104
+ expect ( jwk == other ) . to eq false
105
+ end
106
+
107
+ it 'is not equal to a non-key' do
108
+ other = Object . new
109
+ expect ( jwk == other ) . to eq false
110
+ end
111
+
112
+ it 'is not equal to a different key' do
113
+ other = described_class . new ( 'other-key' )
114
+ expect ( jwk == other ) . to eq false
115
+ end
116
+ end
85
117
end
You can’t perform that action at this time.
0 commit comments