2008-09-21 23:21:30 +08:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2006-07-09 02:14:49 +08:00
|
|
|
require 'test/unit'
|
|
|
|
|
|
|
|
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
2007-09-27 18:19:48 +08:00
|
|
|
$:.unshift File.dirname(__FILE__)
|
2006-07-09 02:14:49 +08:00
|
|
|
require 'active_support'
|
2006-09-04 11:38:13 +08:00
|
|
|
|
2008-09-21 23:21:30 +08:00
|
|
|
if RUBY_VERSION < '1.9'
|
|
|
|
$KCODE = 'UTF8'
|
|
|
|
end
|
|
|
|
|
2008-01-21 11:55:54 +08:00
|
|
|
def uses_gem(gem_name, test_name, version = '> 0')
|
|
|
|
require 'rubygems'
|
|
|
|
gem gem_name.to_s, version
|
|
|
|
require gem_name.to_s
|
|
|
|
yield
|
|
|
|
rescue LoadError
|
|
|
|
$stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again."
|
|
|
|
end
|
|
|
|
|
2007-09-16 05:39:04 +08:00
|
|
|
# Wrap tests that use Mocha and skip if unavailable.
|
2007-10-07 17:15:26 +08:00
|
|
|
unless defined? uses_mocha
|
2008-01-21 11:55:54 +08:00
|
|
|
def uses_mocha(test_name, &block)
|
|
|
|
uses_gem('mocha', test_name, '>= 0.5.5', &block)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-09-04 11:38:13 +08:00
|
|
|
# Show backtraces for deprecated behavior for quicker cleanup.
|
2008-09-21 23:21:30 +08:00
|
|
|
ActiveSupport::Deprecation.debug = true
|