Class: BlueShell::Matchers::OutputMatcher
- Inherits:
-
Object
- Object
- BlueShell::Matchers::OutputMatcher
- Defined in:
- lib/blue-shell/matchers/output_matcher.rb
Instance Attribute Summary collapse
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected_output, timeout = 30) ⇒ OutputMatcher
constructor
A new instance of OutputMatcher.
- #matches?(runner) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected_output, timeout = 30) ⇒ OutputMatcher
Returns a new instance of OutputMatcher.
6 7 8 9 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 6 def initialize(expected_output, timeout = 30) @expected_output = expected_output @timeout = timeout end |
Instance Attribute Details
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 4 def timeout @timeout end |
Instance Method Details
#failure_message ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 18 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
11 12 13 14 15 16 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 11 def matches?(runner) raise Errors::InvalidInputError unless runner.respond_to?(:expect) @matched = runner.expect(@expected_output, @timeout) @full_output = runner.output !!@matched end |
#negative_failure_message ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/blue-shell/matchers/output_matcher.rb', line 27 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 |