Class: Suture::TestsPatient

Inherits:
Object
  • Object
show all
Includes:
Adapter::Log
Defined in:
lib/suture/verify/tests_patient.rb

Instance Method Summary collapse

Methods included from Adapter::Log

#log_debug, #log_error, #log_info, #log_warn, logger, reset!

Constructor Details

#initializeTestsPatient

Returns a new instance of TestsPatient.



14
15
16
# File 'lib/suture/verify/tests_patient.rb', line 14

def initialize
  @administers_test = AdministersTest.new
end

Instance Method Details

#test(test_plan) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/suture/verify/tests_patient.rb', line 18

def test(test_plan)
  validate_test_plan!(test_plan)
  experienced_failure_in_life = false
  timer = Suture::Util::Timer.new(test_plan.time_limit) unless test_plan.time_limit.nil?
  test_cases = build_test_cases(test_plan)
  Value::TestResults.new(test_cases.each_with_index.map { |observation, i|
    if should_skip?(test_plan, experienced_failure_in_life, i, timer)
      {
        :observation => observation,
        :ran => false
      }
    else
      @administers_test.administer(test_plan, observation).merge({
        :observation => observation,
        :ran => true
      }).tap { |r| experienced_failure_in_life = true unless r[:passed] }
    end
  })
end