class RSpecApprovals::Matchers::OutputApproval

Public Instance Methods

matches?(block) click to toggle source

Called by RSpec

Calls superclass method RSpecApprovals::Matchers::Base#matches?
# File lib/rspec_approvals/matchers/output_approval.rb, line 11
def matches?(block)
  return false unless block.is_a? Proc
  @actual = stream_capturer.capture block
  super
end
stream_capturer() click to toggle source
# File lib/rspec_approvals/matchers/output_approval.rb, line 37
def stream_capturer
  @stream_capturer ||= Stream::Stdout
end
supports_block_expectations?() click to toggle source

Lets RSpec know that this matcher requires a block.

# File lib/rspec_approvals/matchers/output_approval.rb, line 18
def supports_block_expectations?
  true
end
to_stderr() click to toggle source

Adds chained matcher, to allow: expect { stream }.to output_approval(file).to_stderr

# File lib/rspec_approvals/matchers/output_approval.rb, line 32
def to_stderr
  @stream_capturer = Stream::Stderr
  self
end
to_stdout() click to toggle source

Adds chained matcher, to allow: expect { stream }.to output_approval(file).to_stdout This is the default, and only provided for completeness.

# File lib/rspec_approvals/matchers/output_approval.rb, line 25
def to_stdout
  @stream_capturer = Stream::Stdout
  self
end