abstract_unit.rb 778 字节
Newer Older
1
require File.expand_path('../../../load_paths', __FILE__)
2

3
require 'test/unit'
4
require 'mocha'
5

6
ENV['NO_RELOAD'] = '1'
7
require 'active_support'
8

J
Joshua Peek 已提交
9 10 11
# Include shims until we get off 1.8.6
require 'active_support/ruby/shim'

12
def uses_memcached(test_name)
13
  require 'memcache'
14 15 16 17 18 19
  begin
    MemCache.new('localhost').stats
    yield
  rescue MemCache::MemCacheError
    $stderr.puts "Skipping #{test_name} tests. Start memcached and try again."
  end
20 21
end

22 23 24 25 26 27 28 29 30 31 32
def with_kcode(code)
  if RUBY_VERSION < '1.9'
    begin
      old_kcode, $KCODE = $KCODE, code
      yield
    ensure
      $KCODE = old_kcode
    end
  else
    yield
  end
33
end
34 35 36 37 38 39 40

# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true

if RUBY_VERSION < '1.9'
  $KCODE = 'UTF8'
end