123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Matchers::BuiltIn::BaseMatcher::HashFormatting Private

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
::RSpec::Matchers::BuiltIn::All, ::RSpec::Matchers::BuiltIn::BaseMatcher, ::RSpec::Matchers::BuiltIn::Be, ::RSpec::Matchers::BuiltIn::BeAKindOf, ::RSpec::Matchers::BuiltIn::BeAnInstanceOf, ::RSpec::Matchers::BuiltIn::BeBetween, ::RSpec::Matchers::BuiltIn::BeComparedTo, ::RSpec::Matchers::BuiltIn::BeFalsey, ::RSpec::Matchers::BuiltIn::BeNil, ::RSpec::Matchers::BuiltIn::BePredicate, ::RSpec::Matchers::BuiltIn::BeTruthy, ::RSpec::Matchers::BuiltIn::BeWithin, ::RSpec::Matchers::BuiltIn::Change, ::RSpec::Matchers::BuiltIn::ChangeFromValue, ::RSpec::Matchers::BuiltIn::ChangeRelatively, ::RSpec::Matchers::BuiltIn::ChangeToValue, ::RSpec::Matchers::BuiltIn::Compound, ::RSpec::Matchers::BuiltIn::Compound::And, ::RSpec::Matchers::BuiltIn::Compound::Or, ::RSpec::Matchers::BuiltIn::ContainExactly, ::RSpec::Matchers::BuiltIn::Cover, ::RSpec::Matchers::BuiltIn::DynamicPredicate, ::RSpec::Matchers::BuiltIn::EndWith, ::RSpec::Matchers::BuiltIn::Eq, ::RSpec::Matchers::BuiltIn::Eql, ::RSpec::Matchers::BuiltIn::Equal, ::RSpec::Matchers::BuiltIn::Exist, ::RSpec::Matchers::BuiltIn::Has, ::RSpec::Matchers::BuiltIn::HaveAttributes, ::RSpec::Matchers::BuiltIn::Include, ::RSpec::Matchers::BuiltIn::Match, ::RSpec::Matchers::BuiltIn::Output, ::RSpec::Matchers::BuiltIn::RespondTo, ::RSpec::Matchers::BuiltIn::Satisfy, ::RSpec::Matchers::BuiltIn::SpecificValuesChange, ::RSpec::Matchers::BuiltIn::StartOrEndWith, ::RSpec::Matchers::BuiltIn::StartWith, ::RSpec::Matchers::BuiltIn::YieldControl, ::RSpec::Matchers::BuiltIn::YieldSuccessiveArgs, ::RSpec::Matchers::BuiltIn::YieldWithArgs, ::RSpec::Matchers::BuiltIn::YieldWithNoArgs, ::RSpec::Rails::Matchers::ActionCable::HaveBroadcastedTo, ::RSpec::Rails::Matchers::ActionCable::HaveStream, ::RSpec::Rails::Matchers::BeValid
Defined in: rspec-expectations/lib/rspec/matchers/built_in/base_matcher.rb

Class Method Summary

Class Method Details

.improve_hash_formatting(inspect_string) (mod_func)

‘{ :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.

[ GitHub ]

  
# File 'rspec-expectations/lib/rspec/matchers/built_in/base_matcher.rb', line 156

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