File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,11 @@ class Description
124
124
# @since 2.0.0
125
125
TAGS = 'tags' . freeze
126
126
127
+ # Fields to exclude when comparing two descriptions.
128
+ #
129
+ # @since 2.0.6
130
+ EXCLUDE_FOR_COMPARISON = [ 'localTime' ]
131
+
127
132
# @return [ Address ] address The server's address.
128
133
attr_reader :address
129
134
@@ -496,7 +501,9 @@ def replica_set_member?
496
501
# @since 2.0.6
497
502
def ==( other )
498
503
return false if self . class != other . class
499
- config == other . config
504
+ !config . keys . empty? && config . keys . all? do |k |
505
+ config [ k ] == other . config [ k ] || EXCLUDE_FOR_COMPARISON . include? ( k )
506
+ end
500
507
end
501
508
alias_method :eql? , :==
502
509
end
Original file line number Diff line number Diff line change 22
22
'maxWriteBatchSize' => 1000 ,
23
23
'maxWireVersion' => 2 ,
24
24
'minWireVersion' => 0 ,
25
+ 'localTime' => Time . now ,
25
26
'ok' => 1
26
27
}
27
28
end
691
692
692
693
describe '#==' do
693
694
695
+ let ( :description ) do
696
+ described_class . new ( address , replica )
697
+ end
698
+
699
+ let ( :other ) do
700
+ described_class . new ( address , replica . merge ( 'localTime' => 1 ) )
701
+ end
702
+
703
+ it 'excludes certain fields' do
704
+ expect ( description == other ) . to be ( true )
705
+ end
706
+
694
707
context 'when the classes do not match' do
695
708
696
709
let ( :description ) do
You can’t perform that action at this time.
0 commit comments