Updated Rails to 2.1.0
[gitorious:georgyos-clone.git] / vendor / plugins / rspec_on_rails / lib / spec / rails / extensions / spec / example / configuration.rb
1 require 'spec/example/configuration'
2
3 module Spec
4   module Example
5     class Configuration
6       # Rails 1.2.3 does a copy of the @inheritable_attributes to the subclass when the subclass is
7       # created. This causes an ordering issue when setting state on Configuration because the data is
8       # already copied.
9       # Iterating over EXAMPLE_GROUP_CLASSES causes the base ExampleGroup classes to have their
10       # @inheritable_attributes updated.
11       # TODO: BT - When we no longer support Rails 1.2.3, we can remove this functionality
12       EXAMPLE_GROUP_CLASSES = [
13         ::Test::Unit::TestCase,
14         ::Spec::Rails::Example::RailsExampleGroup,
15         ::Spec::Rails::Example::FunctionalExampleGroup,
16         ::Spec::Rails::Example::ControllerExampleGroup,
17         ::Spec::Rails::Example::ViewExampleGroup,
18         ::Spec::Rails::Example::HelperExampleGroup,
19         ::Spec::Rails::Example::ModelExampleGroup
20       ]
21       # All of this is ActiveRecord related and makes no sense if it's not used by the app
22       if defined?(ActiveRecord::Base)
23         def initialize
24           super
25           self.fixture_path = RAILS_ROOT + '/spec/fixtures'
26         end
27
28         def use_transactional_fixtures
29           Test::Unit::TestCase.use_transactional_fixtures
30         end
31         def use_transactional_fixtures=(value)
32           EXAMPLE_GROUP_CLASSES.each do |example_group|
33             example_group.use_transactional_fixtures = value
34           end
35         end
36
37         def use_instantiated_fixtures
38           Test::Unit::TestCase.use_instantiated_fixtures
39         end
40         def use_instantiated_fixtures=(value)
41           EXAMPLE_GROUP_CLASSES.each do |example_group|
42             example_group.use_instantiated_fixtures = value
43           end
44         end
45
46         def fixture_path
47           Test::Unit::TestCase.fixture_path
48         end
49         def fixture_path=(path)
50           EXAMPLE_GROUP_CLASSES.each do |example_group|
51             example_group.fixture_path = path
52           end
53         end
54
55         def global_fixtures
56           ::Test::Unit::TestCase.fixture_table_names
57         end
58         def global_fixtures=(fixtures)
59           EXAMPLE_GROUP_CLASSES.each do |example_group|
60             example_group.fixtures(*fixtures)
61           end
62         end
63       end
64     end
65   end
66 end