Sha256: 930498584541e0309cd6bf302ba765ac900c303703dc1d35e8ae7ce14d1bf432

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

# require 'rubygems'
# require 'bundler'
# begin
#   Bundler.setup(:default, :development)
# rescue Bundler::BundlerError => e
#   $stderr.puts e.message
#   $stderr.puts "Run `bundle install` to install missing gems"
#   exit e.status_code
# end
# require 'test/unit'
# require 'rspec'
# 
# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
# $LOAD_PATH.unshift(File.dirname(__FILE__))
# 
# require 'itrigga/core_ext'
# require 'itrigga/net_helper'
# 
# Dir.chdir(File.join(File.dirname(__FILE__), '..'))
# 
# RSpec.configure do |config|
#   # some (optional) config here
# end

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
RAILS_ENV = "test"

require 'itrigga/net_helper'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}


# taken from http://digitaldumptruck.jotabout.com/?p=551
# allows dynamic re-definition of constants, returning them to previous state after the test
# also kills those pesky warnings about 'Constant XXX already defined'
def with_constants(constants, &block)
  saved_constants = {}
  constants.each do |constant, val|
    saved_constants[ constant ] = Object.const_get( constant )
    Kernel::silence_warnings { Object.const_set( constant, val ) }
  end
 
  begin
    block.call
  ensure
    constants.each do |constant, val|
      Kernel::silence_warnings { Object.const_set( constant, saved_constants[ constant ] ) }
    end
  end
end

# taken from activesupport/lib/active_support/core_ext/kernel/reporting.rb
def silence_warnings
  old_verbose, $VERBOSE = $VERBOSE, nil
    yield
  ensure
    $VERBOSE = old_verbose   
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itrigga-net_helper-0.3.0 spec/spec_helper.rb