Sha256: 690bdba8e1af987e2939bc74611122c22fa48c766ca2d8877561818bbc5f6fe8

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

require 'pathname'
require Pathname.new( File.dirname(__FILE__)).join( '../lib/build-tool' ).cleanpath

require 'rubygems'
require 'logging'
require 'sequel'
require 'stringio'
require 'test/unit'

Logging.init :debug, :verbose, :trace, :info, :warn, :error
include Logging.globally
Logging.logger.root.level = :debug
Logging.logger.root.clear_appenders()


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

def assert_signals( obj, signal, &block )
  called = false

  proc = obj.connect( signal ) { called = true }
  yield
  obj.disconnect( signal, &proc )
  assert called, "Slot was called"
end

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

@database = Sequel.sqlite

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
build-tool-0.5.3 test/test_helper.rb