Class: RSpec::Matchers::BuiltIn::Output Private
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::Output
- Defined in:
- lib/rspec/matchers/built_in/output.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides the implementation for output
.
Not intended to be instantiated directly.
Constant Summary
Constants inherited from BaseMatcher
Instance Method Summary collapse
- #description ⇒ String private
- #diffable? ⇒ Boolean private
- #does_not_match?(block) ⇒ Boolean private
- #failure_message ⇒ String private
- #failure_message_when_negated ⇒ String private
-
#initialize(expected) ⇒ Output
constructor
private
A new instance of Output.
- #matches?(block) ⇒ Boolean private
-
#supports_block_expectations? ⇒ True
private
Indicates this matcher matches against a block.
-
#to_stderr ⇒ Object
Tells the matcher to match against stderr.
-
#to_stdout ⇒ Object
Tells the matcher to match against stdout.
Methods inherited from BaseMatcher
Methods included from Composable
#===, #and, #description_of, enumerable?, #or, surface_descriptions_in, #values_match?
Methods included from Pretty
#name, split_words, #to_sentence, #to_word
Constructor Details
#initialize(expected) ⇒ Output
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Output.
10 11 12 13 |
# File 'lib/rspec/matchers/built_in/output.rb', line 10 def initialize(expected) @expected = expected @stream_capturer = NullCapture end |
Instance Method Details
#description ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 60 |
# File 'lib/rspec/matchers/built_in/output.rb', line 54 def description if @expected "output #{description_of @expected} to #{@stream_capturer.name}" else "output to #{@stream_capturer.name}" end end |
#diffable? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 |
# File 'lib/rspec/matchers/built_in/output.rb', line 64 def diffable? true end |
#does_not_match?(block) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/rspec/matchers/built_in/output.rb', line 22 def does_not_match?(block) !matches?(block) && Proc === block end |
#failure_message ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/rspec/matchers/built_in/output.rb', line 42 def "expected block to #{description}, but #{positive_failure_reason}" end |
#failure_message_when_negated ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'lib/rspec/matchers/built_in/output.rb', line 48 def "expected block to not #{description}, but #{negative_failure_reason}" end |
#matches?(block) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 |
# File 'lib/rspec/matchers/built_in/output.rb', line 15 def matches?(block) @block = block return false unless Proc === block @actual = @stream_capturer.capture(block) @expected ? values_match?(@expected, @actual) : captured? end |
#supports_block_expectations? ⇒ True
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Indicates this matcher matches against a block.
71 72 73 |
# File 'lib/rspec/matchers/built_in/output.rb', line 71 def supports_block_expectations? true end |
#to_stderr ⇒ Object
Tells the matcher to match against stderr.
35 36 37 38 |
# File 'lib/rspec/matchers/built_in/output.rb', line 35 def to_stderr @stream_capturer = CaptureStderr self end |
#to_stdout ⇒ Object
Tells the matcher to match against stdout.
28 29 30 31 |
# File 'lib/rspec/matchers/built_in/output.rb', line 28 def to_stdout @stream_capturer = CaptureStdout self end |