Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / radiant_specs / test / .svn / text-base / test_helper.rb.svn-base
blob2545a9c1d56e282a684abdc035258c4a64fe727b
1 unless defined? TEST_ROOT
2   ENV["RAILS_ENV"] = "test"
3   
4   require 'test/unit'
5   
6   TEST_ROOT = File.expand_path(File.dirname(__FILE__))
7   
8   unless defined? RADIANT_ROOT
9     if env_file = ENV["RADIANT_ENV_FILE"]
10       require env_file
11     else
12       require File.expand_path(TEST_ROOT + "/../config/environment")
13     end
14   end
15   require 'test_help'
16   
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.
22     #
23     # Read Mike Clark's excellent walkthrough at
24     #   http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
25     #
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
29     # is recommended.
30     self.use_transactional_fixtures = true
31     
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
38     
39     # Make sure instance installs know where fixtures are
40     self.fixture_path = ["#{TEST_ROOT}/fixtures"]
41     
42     class << self
43       # Class method for test helpers
44       def test_helper(*names)
45         names.each do |name|
46           name = name.to_s
47           name = $1 if name =~ /^(.*?)_test_helper$/i
48           name = name.singularize
49           first_time = true
50           begin
51             constant = (name.camelize + 'TestHelper').constantize
52             self.class_eval { include constant }
53           rescue NameError
54             filename = File.expand_path(TEST_ROOT + '/helpers/' + name + '_test_helper.rb')
55             require filename if first_time
56             first_time = false
57             retry
58           end
59         end
60       end    
61       alias :test_helpers :test_helper
62     end
63   end
64 end