Module: Tst

Defined in:
lib/tst.rb,
lib/tst/reporters/plain.rb,
lib/tst/reporters/pretty.rb

Defined Under Namespace

Modules: Assertions, Reporters Classes: Failure, Result, Results, Runner

Constant Summary collapse

VERSION =
"0.0.3"
SUCCEEDED =

Set up some constants to represent test outcomes.

:success
FAILED =
:failure
RAISED =
:exception

Class Method Summary collapse

Class Method Details

.default_optionsObject

The default options for ‘run`.



138
139
140
# File 'lib/tst.rb', line 138

def self.default_options
  { :reporter => Reporters::Plain.new, :load_paths => [] }
end

.run(glob, options = {}) ⇒ Object

The main entry point.

glob - a String defining which test files to run.

Passed through to Dir[].

Accepted options:

:load_paths - an Array of directories to add to the load path.
:reporter   - a reporter instance (see 'lib/tst/reporters.rb'
              for docs on reporters)


128
129
130
131
132
133
134
135
# File 'lib/tst.rb', line 128

def self.run(glob, options={})
  options = default_options.merge(options)
  $:.unshift(*options[:load_paths])
  results = Results.new
  reporter = options[:reporter]
  Dir[glob].each { |file| Runner.new(file, reporter, results) }
  reporter.summarize(results)
end