Class: BlueShell::Matchers::OutputMatcher
- Inherits:
-
Object
- Object
- BlueShell::Matchers::OutputMatcher
- Defined in:
- lib/blue-shell/matchers/output_matcher.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected_output) ⇒ OutputMatcher
constructor
A new instance of OutputMatcher.
- #matches?(runner) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected_output) ⇒ OutputMatcher
Returns a new instance of OutputMatcher.
4 5 6 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 4 def initialize(expected_output) @expected_output = expected_output end |
Instance Method Details
#failure_message ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 15 def if @expected_output.is_a?(Hash) expected_keys = @expected_output.keys.map{|key| "'#{key}'"}.join(', ') "expected one of #{expected_keys} to be printed, but it wasn't. full output:\n#@full_output" else "expected '#{@expected_output}' to be printed, but it wasn't. full output:\n#@full_output" end end |
#matches?(runner) ⇒ Boolean
8 9 10 11 12 13 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 8 def matches?(runner) raise Errors::InvalidInputError unless runner.respond_to?(:expect) @matched = runner.expect(@expected_output) @full_output = runner.output !!@matched end |
#negative_failure_message ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 24 def if @expected_output.is_a?(Hash) match = @matched else match = @expected_output end "expected '#{match}' to not be printed, but it was. full output:\n#@full_output" end |