Class: NoInspectMatch

Inherits:
Object
  • Object
show all
Defined in:
lib/cuken/cucumber/chef/run_client_steps.rb

Overview

Matcher for regular expression which uses normal string interpolation for the actual (target) value instead of expecting it, as stdout/stderr which get matched against may have lots of newlines, which looks ugly when inspected, as the newlines show up as n

Instance Method Summary collapse

Constructor Details

#initialize(expected_regex) ⇒ NoInspectMatch

Returns a new instance of NoInspectMatch.



214
215
216
# File 'lib/cuken/cucumber/chef/run_client_steps.rb', line 214

def initialize(expected_regex)
  @expected_regex = expected_regex
end

Instance Method Details

#failure_messageObject



221
222
223
# File 'lib/cuken/cucumber/chef/run_client_steps.rb', line 221

def failure_message
  "expected #{@target} should match #{@expected_regex}"
end

#matches?(target) ⇒ Boolean

Returns:

  • (Boolean)


217
218
219
220
# File 'lib/cuken/cucumber/chef/run_client_steps.rb', line 217

def matches?(target)
  @target = target
  @target =~ @expected_regex
end

#negative_failure_messageObject



224
225
226
# File 'lib/cuken/cucumber/chef/run_client_steps.rb', line 224

def negative_failure_message
  "expected #{@target} not to match #{@expected_regex}"
end