Class: Runyoufools::Test
- Inherits:
-
Object
- Object
- Runyoufools::Test
- Defined in:
- lib/runyoufools/test.rb
Instance Attribute Summary collapse
-
#ok ⇒ Object
readonly
Returns the value of attribute ok.
-
#trials ⇒ Object
readonly
Returns the value of attribute trials.
Instance Method Summary collapse
- #_run ⇒ Object
-
#initialize(testFile, retries, command) ⇒ Test
constructor
A new instance of Test.
- #run ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(testFile, retries, command) ⇒ Test
Returns a new instance of Test.
7 8 9 10 11 12 |
# File 'lib/runyoufools/test.rb', line 7 def initialize( testFile, retries, command ) @file = testFile @ok = nil @retries = retries @command = command end |
Instance Attribute Details
#ok ⇒ Object (readonly)
Returns the value of attribute ok.
4 5 6 |
# File 'lib/runyoufools/test.rb', line 4 def ok @ok end |
#trials ⇒ Object (readonly)
Returns the value of attribute trials.
5 6 7 |
# File 'lib/runyoufools/test.rb', line 5 def trials @trials end |
Instance Method Details
#_run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/runyoufools/test.rb', line 24 def _run Runyoufools.log :info, "RUNNING #{@file}" if @command toRun = "#{@command} #{@file}" else toRun = @file end @ok = system( toRun ) if @ok == nil Runyoufools.log :error, "could not execute: #{toRun}" end Runyoufools.log :info,( "#{self}" ) end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/runyoufools/test.rb', line 14 def run @trials = 0 @retries.times do Runyoufools.log :info, "retrying #{@file}..." if @trials > 0 @trials += 1 _run return if @ok end end |
#to_s ⇒ Object
38 39 40 41 |
# File 'lib/runyoufools/test.rb', line 38 def to_s result = { true => "OK ".green.bold, false => "FAIL ".red.bold, nil => "ERROR".white.bold.on_red }[ @ok ] "#{result}: #{@trials} trial(s) : #{@file}" end |