Class: HammerCLI::Testing::OutputMatchers::FieldMatcher
- Inherits:
-
MatcherBase
- Object
- MatcherBase
- HammerCLI::Testing::OutputMatchers::FieldMatcher
- Defined in:
- lib/hammer_cli/testing/output_matchers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #assert_match(test_ctx, actual) ⇒ Object
-
#initialize(label, value) ⇒ FieldMatcher
constructor
A new instance of FieldMatcher.
Constructor Details
#initialize(label, value) ⇒ FieldMatcher
Returns a new instance of FieldMatcher.
17 18 19 |
# File 'lib/hammer_cli/testing/output_matchers.rb', line 17 def initialize(label, value) @expected = FieldMatcher.matcher(label, value) end |
Class Method Details
.matcher(label, value) ⇒ Object
26 27 28 |
# File 'lib/hammer_cli/testing/output_matchers.rb', line 26 def self.matcher(label, value) Regexp.new(Regexp.quote(label) + ':[ ]+' + Regexp.quote(value)) end |
Instance Method Details
#assert_match(test_ctx, actual) ⇒ Object
21 22 23 24 |
# File 'lib/hammer_cli/testing/output_matchers.rb', line 21 def assert_match(test_ctx, actual) = "Regex /#{@expected.source}/ didn't match the output:\n#{actual}" test_ctx.assert(@expected =~ actual, ) end |