@@ -323,6 +323,22 @@ def chdir=(dir)
323323 @chdir = dir . to_s
324324 end
325325
326+ # Procedure to call, just before running tests.
327+ #
328+ # @return [Proc,nil]
329+ def before ( &proc )
330+ @before = proc if proc
331+ @before
332+ end
333+
334+ # Procedure to call, just after running tests.
335+ #
336+ # @return [Proc,nil]
337+ def after ( &proc )
338+ @after = proc if proc
339+ @after
340+ end
341+
326342 # The mode is only useful for specialied purposes, such as how
327343 # to run tests via the Rake task. It has no general purpose
328344 # and can be ignored in most cases.
@@ -390,27 +406,26 @@ def apply_environment_defaults
390406 @loadpath = env ( :loadpath , @loadpath ) if @loadpath . empty?
391407 end
392408
393- # Load configuration file.
409+ # Load configuration file for project.
410+ #
411+ # File names are prefixed with `./` to ensure they are from a local
412+ # source. An extension of `.rb` is assumed if the file lacks an one.
394413 #
395414 # @return [Boolean] true if file was required
396415 def load_config ( file )
397- try_paths = [ 'etc' , 'config' ]
398- try_paths . concat loadpath
399- try_paths << '.'
400- try_paths = try_paths . uniq
416+ file = file + '.rb' if File . extname ( file ) == ''
401417
402418 if chdir
403- try_paths = try_paths . map { |path | File . join ( chdir , path ) }
419+ file = File . join ( chdir , file )
420+ else
421+ file = File . join ( '.' , file )
404422 end
405423
406- hold_path = $LOAD_PATH. dup
407- $LOAD_PATH. replace ( try_paths )
408- begin
409- success = require file
410- ensure
411- $LOAD_PATH. replace ( hold_path )
424+ if File . exist? ( file )
425+ return require ( file )
426+ else
427+ raise "config file not found -- `#{ file } '"
412428 end
413- success
414429 end
415430
416431 private
0 commit comments