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: CaptureHighline
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(example, expected, output, match) ⇒ ShowMatcher
constructor
A new instance of ShowMatcher.
- #matches?(block) ⇒ Boolean
- #to_highline ⇒ Object
Constructor Details
#initialize(example, expected, output, match) ⇒ ShowMatcher
Returns a new instance of ShowMatcher.
11 12 13 14 15 16 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 11 def initialize(example, expected, output, match) super(expected) @example = example @output = output @match = match end |
Instance Method Details
#description ⇒ Object
38 39 40 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 38 def description "#{@stream_capturer.name} to receive the following content (#{@match} match):" end |
#failure_message ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 42 def [ "expected #{description}", "Expected:", "#{@expected}\n", "Actual:", "#{@actual}\n\n" ].join("\n\n") end |
#matches?(block) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 18 def matches?(block) @block = block return false unless Proc === block @expected = @expected.strip if @output == :highline @actual = @stream_capturer.capture(@example.io, block) @actual = @example.strip_heredoc(@actual).strip else @actual = @stream_capturer.capture(block).strip end if @match == :partial values_match?(/#{Regexp.escape(@expected)}/, @actual) else values_match?(@expected, @actual) end end |
#to_highline ⇒ Object
52 53 54 55 |
# File 'lib/wip/runner/spec/helpers/matchers.rb', line 52 def to_highline @stream_capturer = CaptureHighline self end |