aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/test_helper.rb
blob: ccf93280ec6b321cbfa727d9e859b57cd0bb9a71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$:.unshift "#{File.dirname(__FILE__)}/../lib"
$:.unshift File.dirname(__FILE__)

require 'test/unit'
require 'active_model'
require 'active_model/state_machine'
require 'active_support/callbacks' # needed by ActiveModel::TestCase
require 'active_support/test_case'

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

# Wrap tests that use Mocha and skip if unavailable.
unless defined? uses_mocha
  def uses_mocha(test_name, &block)
    uses_gem('mocha', test_name, '>= 0.5.5', &block)
  end
end

begin
  require 'rubygems'
  require 'ruby-debug'
  Debugger.start
rescue LoadError
end

ActiveSupport::TestCase.send :include, ActiveSupport::Testing::Default

module ActiveModel
  class TestCase < ActiveSupport::TestCase
    include ActiveSupport::Testing::Default
  end
end