Module: EcomDev::ChefSpec::Helpers::StringMatcher

Extended by:
StringMatcher
Included in:
StringMatcher
Defined in:
lib/ecomdev/chefspec/helpers/string_matcher.rb

Instance Method Summary collapse

Instance Method Details

#matcher(expected) ⇒ Object



5
6
7
# File 'lib/ecomdev/chefspec/helpers/string_matcher.rb', line 5

def matcher(expected)
  RSpec::Matchers::BuiltIn::Match.new(expected)
end

#regexp(match, before = '', after = '') ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/ecomdev/chefspec/helpers/string_matcher.rb', line 9

def regexp(match, before ='', after = '')
  unless match.is_a?(::Regexp)
    match = ::Regexp.escape(match).tr_s('\\ ', '\\s')
  else
    match = match.source
  end

  ::Regexp.new(before + match + after, Regexp::MULTILINE)
end