Class: Testrus::Tester
- Inherits:
-
Object
- Object
- Testrus::Tester
- Defined in:
- lib/testrus/tester.rb,
lib/testrus/tester/formatter/default.rb
Defined Under Namespace
Modules: Formatter
Constant Summary collapse
- SOURCES =
Internal: Defines the relationship between input sources and their corresponding class names.
{ :file => Testrus::Input::File }
- FORMATTERS =
Internal: Defines the formatters to allow specifying a custom formatter in the options.
{ :default => Formatter::Default }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#formatter ⇒ Object
Public: Returns the formatter class.
-
#initialize(options) ⇒ Tester
constructor
Public: Initializes a tester object.
-
#run ⇒ Object
Public: Runs the input from the source against the runner.
-
#runner ⇒ Object
Public: Returns the instance of the runner which is responsible for running the program against the input.
-
#source ⇒ Object
Public: Maps the human source to the class that is responsible for the given source.
Constructor Details
#initialize(options) ⇒ Tester
Public: Initializes a tester object. The tester is responsible for coordinating the input from the input source and the runner, and passing the final results to the formatter.
options - The Hash containing the options for the Tester:
:source - The Symbol marking the input source, valid options
are defined in the class constant Tester::SOURCES.
:command - The String specifying the command to run program that
the the input will be given to via STDIN.
27 28 29 |
# File 'lib/testrus/tester.rb', line 27 def initialize() @options = .merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/testrus/tester.rb', line 3 def @options end |
Instance Method Details
#formatter ⇒ Object
Public: Returns the formatter class.
46 47 48 |
# File 'lib/testrus/tester.rb', line 46 def formatter FORMATTERS[@options[:formatter]] end |
#run ⇒ Object
Public: Runs the input from the source against the runner. Return the results to the formatter.
52 53 54 55 56 |
# File 'lib/testrus/tester.rb', line 52 def run source.tests.each do |test| formatter.new(runner.run(test)).report end end |
#runner ⇒ Object
Public: Returns the instance of the runner which is responsible for running the program against the input.
41 42 43 |
# File 'lib/testrus/tester.rb', line 41 def runner @runner ||= Testrus::Runner.new([:command]) end |
#source ⇒ Object
Public: Maps the human source to the class that is responsible for the given source.
Returns a corresponding Class constant.
35 36 37 |
# File 'lib/testrus/tester.rb', line 35 def source @source ||= SOURCES[@options[:source]].new end |