Class: HammerCLI::Testing::OutputMatchers::IndexLineMatcher

Inherits:
MatcherBase
  • Object
show all
Defined in:
lib/hammer_cli/testing/output_matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected = []) ⇒ IndexLineMatcher

Returns a new instance of IndexLineMatcher.



75
76
77
# File 'lib/hammer_cli/testing/output_matchers.rb', line 75

def initialize(expected=[])
  @expected_values = expected
end

Instance Method Details

#assert_match(test_ctx, actual) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/hammer_cli/testing/output_matchers.rb', line 79

def assert_match(test_ctx, actual)
  message = [
    "Regex didn't match the output.",
    "Expected regex:",
    line_regexp.source,
    "Expected fields:",
    @expected_values.join(' | '),
    "Actual output:",
    actual
  ].join("\n")

  test_ctx.assert(line_regexp =~ actual, message)
end