1 unless defined? TEST_ROOT
2 ENV["RAILS_ENV"] = "test"
6 TEST_ROOT = File.expand_path(File.dirname(__FILE__))
8 unless defined? RADIANT_ROOT
9 if env_file = ENV["RADIANT_ENV_FILE"]
12 require File.expand_path(TEST_ROOT + "/../config/environment")
17 class Test::Unit::TestCase
18 # Transactional fixtures accelerate your tests by wrapping each test method
19 # in a transaction that's rolled back on completion. This ensures that the
20 # test database remains unchanged so your fixtures don't have to be reloaded
21 # between every test method. Fewer database queries means faster tests.
23 # Read Mike Clark's excellent walkthrough at
24 # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
26 # Every Active Record database supports transactions except MyISAM tables
27 # in MySQL. Turn off transactional fixtures in this case; however, if you
28 # don't care one way or the other, switching from MyISAM to InnoDB tables
30 self.use_transactional_fixtures = true
32 # Instantiated fixtures are slow, but give you @david where otherwise you
33 # would need people(:david). If you don't want to migrate your existing
34 # test cases which use the @david style and don't mind the speed hit (each
35 # instantiated fixtures translates to a database query per test method),
36 # then set this back to true.
37 self.use_instantiated_fixtures = false
39 # Make sure instance installs know where fixtures are
40 self.fixture_path = ["#{TEST_ROOT}/fixtures"]
43 # Class method for test helpers
44 def test_helper(*names)
47 name = $1 if name =~ /^(.*?)_test_helper$/i
48 name = name.singularize
51 constant = (name.camelize + 'TestHelper').constantize
52 self.class_eval { include constant }
54 filename = File.expand_path(TEST_ROOT + '/helpers/' + name + '_test_helper.rb')
55 require filename if first_time
61 alias :test_helpers :test_helper