@@ -27,7 +27,7 @@ module Support
2727 # We can't count on the ordering of the hash on 1.8.7...
2828 expect ( formatted ) . to include ( %Q{"key"=>#{ formatted_time } } , %Q{#{ formatted_time } =>"value"} , %Q{"nested"=>{"key"=>#{ formatted_time } }} )
2929 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 } }}} )
3131 end
3232 end
3333 end
@@ -39,7 +39,7 @@ module Support
3939
4040 it 'sorts keys to ensure objects are always displayed the same way' do
4141 formatted = ObjectFormatter . format ( input )
42- expect ( formatted ) . to eq expected
42+ expect ( formatted ) . to eq_hash_syntax expected
4343 end
4444 end
4545 end
@@ -269,7 +269,7 @@ def self.to_s
269269 let ( :formatted_time ) { ObjectFormatter . format ( time ) }
270270
271271 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 } }" )
273273 end
274274 end
275275
@@ -289,7 +289,7 @@ def self.to_s
289289 let ( :formatted_time ) { ObjectFormatter . format ( time ) }
290290
291291 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 } =>{...}}" )
293293 end
294294 end
295295
@@ -305,7 +305,7 @@ def self.to_s
305305 end
306306
307307 it 'formats the recursive element as [...]' do
308- expect ( output ) . to eq ( '[{:recursive_array=>[...]}]' )
308+ expect ( output ) . to eq_hash_syntax ( '[{:recursive_array=>[...]}]' )
309309 end
310310 end
311311
@@ -321,7 +321,7 @@ def self.to_s
321321 end
322322
323323 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, {...}]}' )
325325 end
326326 end
327327
@@ -336,7 +336,7 @@ def self.to_s
336336 end
337337
338338 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"}]' )
340340 end
341341 end
342342
@@ -370,6 +370,16 @@ def inspect
370370 expect ( formatter . format ( 'Test String Of A Longer Length' ) ) . to eq ( '"Test String Of A Longer Length"' )
371371 end
372372 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
373383 end
374384 end
375385end
0 commit comments