Exception: StderrAssay

Inherits:
OutputAssay show all
Defined in:
lib/assay/stderr_assay.rb

Overview

Assert that there is output $stderr.

StderrAssay.pass?(/foo/){ $stderr.puts 'foo!' }  #=> true

Constant Summary

Constants inherited from Assertion

Assertion::SIZE_LIMIT

Constants included from Assay::Assertable

Assay::Assertable::SIZE_LIMIT

Class Method Summary collapse

Methods inherited from Assertion

by_name, by_operator, inherited, register, subclasses

Methods included from Assay::Assertable

#[], #assert!, #assert_message, #assertive_name, #assertor, #fail?, #operator, #pass?, #refute!, #refute_message

Class Method Details

.pass?(match, &block) ⇒ Boolean

Check assertion via ‘#===` method.

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/assay/stderr_assay.rb', line 14

def self.pass?(match, &block)
  require 'stringio'

  begin
    stderr  = $stderr
    newerr  = StringIO.new
    $stderr = newerr
    yield  
  ensure
    $stderr = stderr
  end

  match === newerr.string.chomp("\n")
end