Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / radiant_specs / spec / .svn / text-base / spec_helper.rb.svn-base
blobce900aad8ca4483dfca300b2edf0490ec5d22342
1 unless defined? SPEC_ROOT
2   ENV["RAILS_ENV"] = "test"
3   
4   SPEC_ROOT = File.expand_path(File.dirname(__FILE__))
5   
6   unless defined? RADIANT_ROOT
7     if env_file = ENV["RADIANT_ENV_FILE"]
8       require env_file
9     else
10       require File.expand_path(SPEC_ROOT + "/../config/environment")
11     end
12   end
13   require 'spec'
14   require 'spec/rails'
15   require 'scenarios'
16   
17   class Test::Unit::TestCase
18     class << self
19       # Class method for test helpers
20       def test_helper(*names)
21         names.each do |name|
22           name = name.to_s
23           name = $1 if name =~ /^(.*?)_test_helper$/i
24           name = name.singularize
25           first_time = true
26           begin
27             constant = (name.camelize + 'TestHelper').constantize
28             self.class_eval { include constant }
29           rescue NameError
30             filename = File.expand_path(SPEC_ROOT + '/../test/helpers/' + name + '_test_helper.rb')
31             require filename if first_time
32             first_time = false
33             retry
34           end
35         end
36       end    
37       alias :test_helpers :test_helper
38     end
39   end
40   
41   Dir[RAILS_ROOT + '/spec/matchers/*_matcher.rb'].each do |matcher|
42     require matcher
43   end
44   
45   Spec::Runner.configure do |config|
46     config.use_transactional_fixtures = true
47     config.use_instantiated_fixtures  = false
48     config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
49     
50     # You can declare fixtures for each behaviour like this:
51     #   describe "...." do
52     #     fixtures :table_a, :table_b
53     #
54     # Alternatively, if you prefer to declare them only once, you can
55     # do so here, like so ...
56     #
57     #   config.global_fixtures = :table_a, :table_b
58     #
59     # If you declare global fixtures, be aware that they will be declared
60     # for all of your examples, even those that don't use them.
61   end
62 end