Exception: StdoutAssay

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

Overview

Assert that there is output, either from stdout or stderr.

StdoutAssay.pass?(/foo/){ 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/stdout_assay.rb', line 14

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

  begin
    stdout  = $stdout
    newout  = StringIO.new
    $stdout = newout
    yield
  ensure
    $stdout = stdout
  end

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