Class: Monolens::Command::Tester
- Inherits:
-
Object
- Object
- Monolens::Command::Tester
- Includes:
- Minitest::Assertions
- Defined in:
- lib/monolens/command/tester.rb
Instance Attribute Summary collapse
-
#nb_errors ⇒ Object
Returns the value of attribute nb_errors.
-
#nb_failures ⇒ Object
Returns the value of attribute nb_failures.
-
#nb_successes ⇒ Object
Returns the value of attribute nb_successes.
-
#nb_tests ⇒ Object
Returns the value of attribute nb_tests.
Instance Method Summary collapse
- #call(lens) ⇒ Object
-
#initialize(command) ⇒ Tester
constructor
A new instance of Tester.
Constructor Details
#initialize(command) ⇒ Tester
Returns a new instance of Tester.
8 9 10 11 12 13 14 15 |
# File 'lib/monolens/command/tester.rb', line 8 def initialize(command) @command = command @nb_tests = 0 @nb_successes = 0 @nb_errors = 0 @nb_failures = 0 Paint.mode = command.use_paint? ? Paint.detect_mode : 0 end |
Instance Attribute Details
#nb_errors ⇒ Object
Returns the value of attribute nb_errors.
16 17 18 |
# File 'lib/monolens/command/tester.rb', line 16 def nb_errors @nb_errors end |
#nb_failures ⇒ Object
Returns the value of attribute nb_failures.
16 17 18 |
# File 'lib/monolens/command/tester.rb', line 16 def nb_failures @nb_failures end |
#nb_successes ⇒ Object
Returns the value of attribute nb_successes.
16 17 18 |
# File 'lib/monolens/command/tester.rb', line 16 def nb_successes @nb_successes end |
#nb_tests ⇒ Object
Returns the value of attribute nb_tests.
16 17 18 |
# File 'lib/monolens/command/tester.rb', line 16 def nb_tests @nb_tests end |
Instance Method Details
#call(lens) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/monolens/command/tester.rb', line 18 def call(lens) fail!("No tests found (#{lens.class})") unless lens.is_a?(Monolens::File) self.nb_tests = lens.examples.size details = [] lens.examples.each_with_index do |example, i| test_one(lens, example, i, details) end stdout.puts("\n") stdout.puts("\n") unless details.empty? details.each do || stdout.puts() end success = nb_errors == 0 && nb_failures == 0 stdout.puts(success ? green(last_sentence) : red(last_sentence)) do_exit(1) unless success end |