Sha256: 82c6480aed7b219e38b3a80f1d1e569f2fb35424c167de3956dc10d77ac0db29

Contents?: true

Size: 1.35 KB

Versions: 24

Compression:

Stored size: 1.35 KB

Contents

require 'rubygems'
require 'test/unit'
require 'tmpdir'
require 'shoulda'
begin
  require 'redgreen'
rescue LoadError
  # Does not work on Ruby 1.9.1, but it is not really needed
end

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'csd'
require 'csd/vendor/zentest/zentest_assertions'

# This will cause tests to be executed which require Internet connection
ONLINE = system 'ping -c 1 www.google.com'
puts "WARNING:".red.blink + " Tests which require Internet connectivity will not be executed!".red unless ONLINE

class Test::Unit::TestCase
  
  # Even though the CSD library offers this function as an Kernel extension, we override it here.
  # It must be guaranteed it works during running the tests.
  #
  def superuser?
    Process.uid == 0
  end
  
  def ensure_mkdir(target)
    target = Pathname.new(target) unless target.is_a?(Pathname)
    target.mkpath
    assert target.directory?
    target
  end
  
  def assert_includes(elem, array, message = nil) 
    message = build_message message, ' is not found in .', elem, array 
    assert_block message do 
      array.include? elem 
    end 
  end
  
  def assert_excludes(elem, array, message = nil) 
    message = build_message message, ' is found in .', elem, array 
    assert_block message do 
      !array.include? elem 
    end 
  end
  
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
csd-0.4.3 test/helper.rb
csd-0.4.2 test/helper.rb
csd-0.4.1 test/helper.rb
csd-0.4.0 test/helper.rb
csd-0.3.7 test/helper.rb
csd-0.3.6 test/helper.rb
csd-0.3.5 test/helper.rb
csd-0.3.4 test/helper.rb
csd-0.3.3 test/helper.rb
csd-0.3.2 test/helper.rb
csd-0.3.1 test/helper.rb
csd-0.3.0 test/helper.rb
csd-0.2.2 test/helper.rb
csd-0.2.1 test/helper.rb
csd-0.2.0 test/helper.rb
csd-0.1.18 test/helper.rb
csd-0.1.17 test/helper.rb
csd-0.1.16 test/helper.rb
csd-0.1.15 test/helper.rb
csd-0.1.14 test/helper.rb