Sha256: 6564b3ce75e401c85b48fd272f7e46cb0232f1a12b7c4c06becab08d3c59f881

Contents?: true

Size: 517 Bytes

Versions: 3

Compression:

Stored size: 517 Bytes

Contents

module Helpers
  module Output
    def assert_output(expected, &block)
      keep_stdout do |stdout|
        block.call
        if expected.is_a?(Regexp)
          assert_match expected, stdout.string
        else
          assert_equal expected.to_s, stdout.string
        end
      end
    end

    def keep_stdout(&block)
      begin
        orig_stream, $stdout = $stdout, StringIO.new
        block.call($stdout)
      ensure
        s, $stdout = $stdout.string, orig_stream
        s
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gemwhois-0.2.1 test/helpers/output.rb
gemwhois-0.2 test/helpers/output.rb
gemwhois-0.1 test/helpers/output.rb