@@ -27,7 +27,7 @@ module Support
27
27
# We can't count on the ordering of the hash on 1.8.7...
28
28
expect ( formatted ) . to include ( %Q{"key"=>#{ formatted_time } } , %Q{#{ formatted_time } =>"value"} , %Q{"nested"=>{"key"=>#{ formatted_time } }} )
29
29
else
30
- expect ( formatted ) . to eq ( %Q{{"key"=>#{ formatted_time } , #{ formatted_time } =>"value", "nested"=>{"key"=>#{ formatted_time } }}} )
30
+ expect ( formatted ) . to eq_hash_syntax ( %Q{{"key"=>#{ formatted_time } , #{ formatted_time } =>"value", "nested"=>{"key"=>#{ formatted_time } }}} )
31
31
end
32
32
end
33
33
end
@@ -39,7 +39,7 @@ module Support
39
39
40
40
it 'sorts keys to ensure objects are always displayed the same way' do
41
41
formatted = ObjectFormatter . format ( input )
42
- expect ( formatted ) . to eq expected
42
+ expect ( formatted ) . to eq_hash_syntax expected
43
43
end
44
44
end
45
45
end
@@ -269,7 +269,7 @@ def self.to_s
269
269
let ( :formatted_time ) { ObjectFormatter . format ( time ) }
270
270
271
271
it 'formats the recursive element as {...} and other elements with custom formatting' do
272
- expect ( output ) . to eq ( "{{...}=>#{ formatted_time } }" )
272
+ expect ( output ) . to eq_hash_syntax ( "{{...}=>#{ formatted_time } }" )
273
273
end
274
274
end
275
275
@@ -289,7 +289,7 @@ def self.to_s
289
289
let ( :formatted_time ) { ObjectFormatter . format ( time ) }
290
290
291
291
it 'formats the recursive element as {...} and other elements with custom formatting' do
292
- expect ( output ) . to eq ( "{#{ formatted_time } =>{...}}" )
292
+ expect ( output ) . to eq_hash_syntax ( "{#{ formatted_time } =>{...}}" )
293
293
end
294
294
end
295
295
@@ -305,7 +305,7 @@ def self.to_s
305
305
end
306
306
307
307
it 'formats the recursive element as [...]' do
308
- expect ( output ) . to eq ( '[{:recursive_array=>[...]}]' )
308
+ expect ( output ) . to eq_hash_syntax ( '[{:recursive_array=>[...]}]' )
309
309
end
310
310
end
311
311
@@ -321,7 +321,7 @@ def self.to_s
321
321
end
322
322
323
323
it 'formats the recursive element as {...}' do
324
- expect ( output ) . to eq ( '{:array=>[:next_is_recursive_hash, {...}]}' )
324
+ expect ( output ) . to eq_hash_syntax ( '{:array=>[:next_is_recursive_hash, {...}]}' )
325
325
end
326
326
end
327
327
@@ -336,7 +336,7 @@ def self.to_s
336
336
end
337
337
338
338
it 'does not omit them' do
339
- expect ( output ) . to eq ( '[{:key=>"value"}, {:key=>"value"}]' )
339
+ expect ( output ) . to eq_hash_syntax ( '[{:key=>"value"}, {:key=>"value"}]' )
340
340
end
341
341
end
342
342
@@ -370,6 +370,16 @@ def inspect
370
370
expect ( formatter . format ( 'Test String Of A Longer Length' ) ) . to eq ( '"Test String Of A Longer Length"' )
371
371
end
372
372
end
373
+
374
+ if RUBY_VERSION . to_f > 3.3
375
+ def eq_hash_syntax ( string )
376
+ eq string . gsub ( '=>' , ' => ' )
377
+ end
378
+ else
379
+ def eq_hash_syntax ( string )
380
+ eq string
381
+ end
382
+ end
373
383
end
374
384
end
375
385
end
0 commit comments