Class: HammerCLI::Testing::OutputMatchers::OutputMatcher
- Inherits:
-
MatcherBase
- Object
- MatcherBase
- HammerCLI::Testing::OutputMatchers::OutputMatcher
- Defined in:
- lib/hammer_cli/testing/output_matchers.rb
Instance Attribute Summary collapse
-
#expected_lines ⇒ Object
Returns the value of attribute expected_lines.
Instance Method Summary collapse
- #assert_match(test_ctx, actual) ⇒ Object
-
#initialize(expected = "", options = {}) ⇒ OutputMatcher
constructor
A new instance of OutputMatcher.
Constructor Details
#initialize(expected = "", options = {}) ⇒ OutputMatcher
Returns a new instance of OutputMatcher.
34 35 36 37 |
# File 'lib/hammer_cli/testing/output_matchers.rb', line 34 def initialize(expected="", ={}) @expected_lines = expected.is_a?(Array) ? expected : [expected] @ignore_whitespace = .fetch(:ignore_whitespace, true) end |
Instance Attribute Details
#expected_lines ⇒ Object
Returns the value of attribute expected_lines.
32 33 34 |
# File 'lib/hammer_cli/testing/output_matchers.rb', line 32 def expected_lines @expected_lines end |
Instance Method Details
#assert_match(test_ctx, actual) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hammer_cli/testing/output_matchers.rb', line 39 def assert_match(test_ctx, actual) if @ignore_whitespace expected_lines = strip_lines(@expected_lines) actual = strip_lines(actual.split("\n")).join("\n") else expected_lines = @expected_lines end expected_lines = expected_lines.join("\n") = "Output didn't contain expected lines:\n" + diff(expected_lines, actual) test_ctx.assert(actual.include?(expected_lines), ) end |