Class: RSpec::Matchers::BuiltIn::Output

### Home Classes Methods

### In Files

- lib/rspec/matchers/built_in/output.rb

### Parent

RSpec::Matchers::BuiltIn::BaseMatcher

### Methods

- ::new
- #description
- #diffable?
- #does_not_match?
- #failure_message
- #failure_message_when_negated
- #matches?
- #supports_block_expectations?
- #to_stderr
- #to_stderr_from_any_process
- #to_stdout
- #to_stdout_from_any_process

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Expectations
- RSpec::Expectations::BlockExpectationTarget
- RSpec::Expectations::Configuration
- RSpec::Expectations::ExpectationHelper
- RSpec::Expectations::ExpectationNotMetError
- RSpec::Expectations::ExpectationTarget
- RSpec::Expectations::LegacyMacherAdapter
- RSpec::Expectations::LegacyMatcherAdapter
- RSpec::Expectations::LegacyMatcherAdapter::RSpec1
- RSpec::Expectations::LegacyMatcherAdapter::RSpec2
- RSpec::Expectations::NegativeExpectationHandler
- RSpec::Expectations::PositiveExpectationHandler
- RSpec::Expectations::Syntax
- RSpec::Expectations::Version
- RSpec::Matchers
- RSpec::Matchers::AliasedMatcher
- RSpec::Matchers::AliasedMatcherWithOperatorSupport
- RSpec::Matchers::AliasedNegatedMatcher
- RSpec::Matchers::BuiltIn
- RSpec::Matchers::BuiltIn::All
- RSpec::Matchers::BuiltIn::BaseMatcher
- RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages
- RSpec::Matchers::BuiltIn::Be
- RSpec::Matchers::BuiltIn::BeAKindOf
- RSpec::Matchers::BuiltIn::BeAnInstanceOf
- RSpec::Matchers::BuiltIn::BeBetween
- RSpec::Matchers::BuiltIn::BeComparedTo
- RSpec::Matchers::BuiltIn::BeFalsey
- RSpec::Matchers::BuiltIn::BeHelpers
- RSpec::Matchers::BuiltIn::BeNil
- RSpec::Matchers::BuiltIn::BePredicate
- RSpec::Matchers::BuiltIn::BeTruthy
- RSpec::Matchers::BuiltIn::BeWithin
- RSpec::Matchers::BuiltIn::CaptureStderr
- RSpec::Matchers::BuiltIn::CaptureStdout
- RSpec::Matchers::BuiltIn::CaptureStreamToTempfile
- RSpec::Matchers::BuiltIn::Change
- RSpec::Matchers::BuiltIn::ChangeDetails
- RSpec::Matchers::BuiltIn::ChangeFromValue
- RSpec::Matchers::BuiltIn::ChangeRelatively
- RSpec::Matchers::BuiltIn::ChangeToValue
- RSpec::Matchers::BuiltIn::Compound
- RSpec::Matchers::BuiltIn::Compound::And
- RSpec::Matchers::BuiltIn::Compound::NestedEvaluator
- RSpec::Matchers::BuiltIn::Compound::Or
- RSpec::Matchers::BuiltIn::Compound::SequentialEvaluator
- RSpec::Matchers::BuiltIn::ContainExactly
- RSpec::Matchers::BuiltIn::ContainExactly::PairingsMaximizer
- RSpec::Matchers::BuiltIn::Cover
- RSpec::Matchers::BuiltIn::EndWith
- RSpec::Matchers::BuiltIn::Eq
- RSpec::Matchers::BuiltIn::Eql
- RSpec::Matchers::BuiltIn::Equal
- RSpec::Matchers::BuiltIn::Exist
- RSpec::Matchers::BuiltIn::Exist::ExistenceTest
- RSpec::Matchers::BuiltIn::Has
- RSpec::Matchers::BuiltIn::HaveAttributes
- RSpec::Matchers::BuiltIn::Include
- RSpec::Matchers::BuiltIn::Match
- RSpec::Matchers::BuiltIn::NegativeOperatorMatcher
- RSpec::Matchers::BuiltIn::NullCapture
- RSpec::Matchers::BuiltIn::OperatorMatcher
- RSpec::Matchers::BuiltIn::Output
- RSpec::Matchers::BuiltIn::PositiveOperatorMatcher
- RSpec::Matchers::BuiltIn::RaiseError
- RSpec::Matchers::BuiltIn::RespondTo
- RSpec::Matchers::BuiltIn::Satisfy
- RSpec::Matchers::BuiltIn::SpecificValuesChange
- RSpec::Matchers::BuiltIn::StartAndEndWith
- RSpec::Matchers::BuiltIn::StartOrEndWith
- RSpec::Matchers::BuiltIn::StartWith
- RSpec::Matchers::BuiltIn::ThrowSymbol
- RSpec::Matchers::BuiltIn::YieldControl
- RSpec::Matchers::BuiltIn::YieldProbe
- RSpec::Matchers::BuiltIn::YieldSuccessiveArgs
- RSpec::Matchers::BuiltIn::YieldWithArgs
- RSpec::Matchers::BuiltIn::YieldWithNoArgs
- RSpec::Matchers::Composable
- RSpec::Matchers::DSL
- RSpec::Matchers::DSL::DefaultImplementations
- RSpec::Matchers::DSL::Macros
- RSpec::Matchers::DSL::Macros::Deprecated
- RSpec::Matchers::DSL::Matcher
- RSpec::Matchers::ExpectedsForMultipleDiffs
- RSpec::Matchers::MatcherDelegator
- RSpec::Matchers::MatcherProtocol
- RSpec::Matchers::Pretty
- BasicObject
- Object

No matching classes.

# RSpec::Matchers::BuiltIn::Output

@api private Provides the implementation for `output`. Not intended to be instantiated directly.

### Public Class Methods

new(expected) click to toggle source

    # File lib/rspec/matchers/built_in/output.rb, line 11
    def initialize(expected)
      @expected        = expected
      @actual          = ""
      @block           = nil
      @stream_capturer = NullCapture
    end

### Public Instance Methods

description() click to toggle source

@api private @return [String]

    # File lib/rspec/matchers/built_in/output.rb, line 77
    def description
      if @expected
        "output #{description_of @expected} to #{@stream_capturer.name}"
      else
        "output to #{@stream_capturer.name}"
      end
    end

diffable?() click to toggle source

@api private @return [Boolean]

    # File lib/rspec/matchers/built_in/output.rb, line 87
    def diffable?
      true
    end

does_not_match?(block) click to toggle source

    # File lib/rspec/matchers/built_in/output.rb, line 25
    def does_not_match?(block)
      !matches?(block) && Proc === block
    end

failure_message() click to toggle source

@api private @return [String]

    # File lib/rspec/matchers/built_in/output.rb, line 65
    def failure_message
      "expected block to #{description}, but #{positive_failure_reason}"
    end

failure_message_when_negated() click to toggle source

@api private @return [String]

    # File lib/rspec/matchers/built_in/output.rb, line 71
    def failure_message_when_negated
      "expected block to not #{description}, but #{negative_failure_reason}"
    end

matches?(block) click to toggle source

    # File lib/rspec/matchers/built_in/output.rb, line 18
    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?() click to toggle source

@api private Indicates this matcher matches against a block. @return [True]

    # File lib/rspec/matchers/built_in/output.rb, line 94
    def supports_block_expectations?
      true
    end

to_stderr() click to toggle source

@api public Tells the matcher to match against stderr. Works only when the main Ruby process prints to stderr

    # File lib/rspec/matchers/built_in/output.rb, line 40
    def to_stderr
      @stream_capturer = CaptureStderr
      self
    end

to_stderr_from_any_process() click to toggle source

@api public Tells the matcher to match against stderr. Works when subprocesses print to stderr as well. This is significantly (~30x) slower than `to_stderr`

    # File lib/rspec/matchers/built_in/output.rb, line 58
    def to_stderr_from_any_process
      @stream_capturer = CaptureStreamToTempfile.new("stderr", $stderr)
      self
    end

to_stdout() click to toggle source

@api public Tells the matcher to match against stdout. Works only when the main Ruby process prints to stdout

    # File lib/rspec/matchers/built_in/output.rb, line 32
    def to_stdout
      @stream_capturer = CaptureStdout
      self
    end

to_stdout_from_any_process() click to toggle source

@api public Tells the matcher to match against stdout. Works when subprocesses print to stdout as well. This is significantly (~30x) slower than `to_stdout`

    # File lib/rspec/matchers/built_in/output.rb, line 49
    def to_stdout_from_any_process
      @stream_capturer = CaptureStreamToTempfile.new("stdout", $stdout)
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.