class Tst::Runner
Runs test files in a fresh scope. It's not perfectly isolated, since requires can still add to the global scope, but it's good enough.
Public Class Methods
new(file, reporter, results)
click to toggle source
# File lib/tst.rb, line 84 def initialize(file, reporter, results) @__reporter = reporter @__results = results __run_tests(file) end
Public Instance Methods
__record(name, status, elapsed, exception=nil)
click to toggle source
# File lib/tst.rb, line 112 def __record(name, status, elapsed, exception=nil) result = Result.new(name, status, elapsed, exception) @__results << result @__reporter.send(status, result) end
__run_tests(file)
click to toggle source
Runs the tests by `instance-eval`-ing the test file.
# File lib/tst.rb, line 91 def __run_tests(file) instance_eval(File.read(file), File.expand_path(file), 1) end
tst(name, &block)
click to toggle source
The `tst` methods itself. Takes a `name` and a block. Runs the block. Records the result.
# File lib/tst.rb, line 99 def tst(name, &block) start = Time.now block.call status = SUCCEEDED rescue Failure => exception status = FAILED rescue StandardError => exception status = RAISED ensure elapsed = Time.now - start __record(name, status, elapsed, exception) end