Sha256: 57cc012124cd9e0fe0064596ddf2aa78f9000fdb4f82879efdb1925c7c16204a

Contents?: true

Size: 588 Bytes

Versions: 9

Compression:

Stored size: 588 Bytes

Contents

# frozen_string_literal: true

RSpec::Matchers.define :match_stdout do |check|
  @capture = nil

  match do |block|
    begin
      stdout_saved = $stdout

      $stdout = StringIO.new

      block.call
    ensure
      @capture = $stdout

      $stdout = stdout_saved
    end

    @capture.string.match check
  end

  failure_message do
    "expected to #{description}"
  end

  failure_message_when_negated do
    "expected not to #{description}"
  end

  description do
    "match [#{check}] on stdout [#{@capture.string}]"
  end

  def supports_block_expectations?
    true
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
archangel-0.4.0 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.3.0 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.0.8 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.0.7 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.0.6 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.0.5 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.0.4 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.0.3 lib/archangel/testing_support/matchers/match_stdout.rb
archangel-0.0.2 lib/archangel/testing_support/matchers/match_stdout.rb