@@ -15,42 +15,54 @@ def self.configuration
1515 @config ||= Config . new
1616 end
1717
18- # Handle test run configruation.
19- #
20- # @todo Why not use the instace level for `Test.config` ?
18+ ##
19+ # Encapsulates test run configruation.
2120 #
2221 class Config
2322
2423 # Default report is in the old "dot-progress" format.
2524 DEFAULT_FORMAT = 'dotprogress'
2625
27- ## RubyTest configuration file can be in `etc/test.rb` or `config/test.rb`,
28- ## or the hidden file `.test.rb`.
29- #GLOB_CONFIG = '{.,task/,etc/,config/}test{.rb,}'
30-
3126 # Glob used to find project root directory.
3227 GLOB_ROOT = '{.index,.gemspec,.git,.hg,_darcs,lib/}'
3328
34- ##
35- ## Load configuration file. This will first look for a root level `Testfile.rb`
36- ## or `.test.rb` file. Failing that it will look for `task/*.test.rb` files.
37- ## An example entry into any of these look like:
38- ##
39- ## Test.run :name do |run|
40- ## run.files << 'test/case_*.rb'
41- ## end
42- ##
43- ## Use `default` for name for non-specific profile and `common` for code that
44- ## should apply to all configurations.
45- ##
46- #def self.load_config
47- # require config_file if config_file
48- #end
29+ # RubyTest configuration file can be in `.test`, '.test.rb`, `etc/test.rb`
30+ # or `config/test.rb`.
31+ #
32+ # @deprecated Use manual -c/--config option instead.
33+ GLOB_CONFIG = '{.test,.test.rb,etc/test.rb,config/test.rb}'
4934
50- ## Find traditional configuration file.
51- #def self.config_file
52- # @config_file ||= Dir.glob(File.join(root, GLOB_CONFIG)).first
53- #end
35+ #
36+ def self . assertionless
37+ @assertionless
38+ end
39+
40+ #
41+ def self . assertionless = ( boolean )
42+ @assertionaless = !!boolean
43+ end
44+
45+ # Load configuration file. An example file might look like:
46+ #
47+ # Test.configure do |run|
48+ # run.files << 'test/case_*.rb'
49+ # end
50+ #
51+ # @deprecated Planned for deprecation in April 2013.
52+ def self . load_config
53+ if config_file
54+ file = config_file . sub ( Dir . pwd +'/' , '' )
55+ $stderr. puts "Automatic #{ file } loading has been deprecated. Use -c option for future version."
56+ load config_file
57+ end
58+ end
59+
60+ # Find traditional configuration file.
61+ #
62+ # @deprecated
63+ def self . config_file
64+ @config_file ||= Dir . glob ( File . join ( root , GLOB_CONFIG ) ) . first
65+ end
5466
5567 # Find and cache project root directory.
5668 #
@@ -83,10 +95,14 @@ def self.dotindex
8395 )
8496 end
8597
98+ # Require a configuration file.
8699 #
87100 # TODO: Should config files be require relative to project root
88101 # or relatvie to current working directory?
89102 #
103+ # TODO: Use load instead of require?
104+ #
105+ # @return nothing.
90106 def self . require_config ( file )
91107 #if File.exist?(file)
92108 # require file
@@ -114,12 +130,13 @@ def self.load_path_setup
114130 end
115131 end
116132
117- #
133+ # Initialize new Config instance.
118134 def initialize ( &block )
135+ self . class . load_config
119136 apply ( &block )
120137 end
121138
122- #
139+ # Evaluate configuration block.
123140 def apply ( &block )
124141 block . call ( self ) if block
125142 end
@@ -142,17 +159,17 @@ def format
142159 @format || ENV [ 'RUBYTEST_FORMAT' ] || DEFAULT_FORMAT
143160 end
144161
145- #
162+ # Set test report format.
146163 def format = ( format )
147164 @format = format
148165 end
149166
150- #
167+ # Provide extra details in reports?
151168 def verbose
152169 @verbose
153170 end
154171
155- #
172+ # Set verbose mode.
156173 def verbose = ( boolean )
157174 @verbose = !!boolean
158175 end
@@ -174,7 +191,7 @@ def units
174191
175192 # Hard is a synonym for assertionless.
176193 def hard
177- @hard || Runner . assertionless
194+ @hard || self . class . assertionless
178195 end
179196
180197 # Hard is a synonym for assertionless.
0 commit comments