Module: Aruba::Matchers::BaseMatcher::HashFormatting

Included in:
Aruba::Matchers::BaseMatcher
Defined in:
lib/aruba/matchers/base/base_matcher.rb

Class Method Summary collapse

Class Method Details

.improve_hash_formatting(inspect_string) ⇒ Object

`{ :a => 5, :b => 2 }.inspect` produces:

{:a=>5, :b=>2}

…but it looks much better as:

{:a => 5, :b => 2}

This is idempotent and safe to run on a string multiple times.


45
46
47
# File 'lib/aruba/matchers/base/base_matcher.rb', line 45

def improve_hash_formatting(inspect_string)
  inspect_string.gsub(/(\S)=>(\S)/, '\1 => \2')
end