Class: WIP::Runner::Spec::Helpers::Matchers::ShowMatcher
- Inherits:
-
RSpec::Matchers::BuiltIn::Output
- Object
- RSpec::Matchers::BuiltIn::Output
- WIP::Runner::Spec::Helpers::Matchers::ShowMatcher
- Defined in:
- lib/wip/runner/spec/helpers/matchers.rb
Defined Under Namespace
Modules: Capturer
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(example, expected, stream, match) ⇒ ShowMatcher
constructor
A new instance of ShowMatcher.
- #matches?(block) ⇒ Boolean
Constructor Details
#initialize(example, expected, stream, match) ⇒ ShowMatcher
Returns a new instance of ShowMatcher.
13 14 15 16 17 18 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 13 def initialize(example, expected, stream, match) super(expected) @example = example @stream = stream @match = match end |
Instance Method Details
#description ⇒ Object
35 36 37 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 35 def description "STD#{@stream.upcase} to receive the following content (#{@match} match):" end |
#failure_message ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 39 def [ "expected #{description}", "Expected:", "#{@expected}\n", "Actual:", "#{@actual}\n\n" ].join("\n\n") end |
#matches?(block) ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 20 def matches?(block) @block = block return false unless Proc === block @expected = @expected.strip @actual = Capturer.capture(@example.ui, @stream, block) @actual = @example.strip_heredoc(@actual).strip if @match == :partial values_match?(/#{Regexp.escape(@expected)}/, @actual) else values_match?(@expected, @actual) end end |