Class: CIAT::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/ciat/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ciat_file, processors, feedback) ⇒ Test

:nodoc:



9
10
11
12
13
# File 'lib/ciat/test.rb', line 9

def initialize(ciat_file, processors, feedback) #:nodoc:
  @ciat_file = ciat_file
  @processors = processors
  @feedback = feedback
end

Instance Attribute Details

#processorsObject (readonly)

Returns the value of attribute processors.



7
8
9
# File 'lib/ciat/test.rb', line 7

def processors
  @processors
end

Instance Method Details

#groupingObject



19
20
21
# File 'lib/ciat/test.rb', line 19

def grouping
  @ciat_file.grouping
end

#make_subtestsObject



51
52
53
54
55
# File 'lib/ciat/test.rb', line 51

def make_subtests
  processors.map do |processor|
    CIAT::Subtest.new(@ciat_file, processor)
  end
end

#remaining_subtests(subtests, light) ⇒ Object



39
40
41
# File 'lib/ciat/test.rb', line 39

def remaining_subtests(subtests, light)
  subtests.map { |subtest| subresult(subtest, light) }
end

#runObject



15
16
17
# File 'lib/ciat/test.rb', line 15

def run
  CIAT::TestResult.new(@ciat_file, run_subtests)
end

#run_subtestsObject

:nodoc:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ciat/test.rb', line 23

def run_subtests #:nodoc:
  subtests = make_subtests
  subresults = []
  until subtests.empty?
    subtest = subtests.shift
    subresults << subresult(subtest, subtest.process)
    if subtest.sad_path?
      return subresults + remaining_subtests(subtests, unneeded)
    end
    unless subresults.last.light.green?
      return subresults + remaining_subtests(subtests, unset)
    end
  end
  subresults
end

#subresult(subtest, light) ⇒ Object



57
58
59
60
61
62
# File 'lib/ciat/test.rb', line 57

def subresult(subtest, light)
  subresult = CIAT::Subresult.new(@ciat_file,
    subtest.path_kind, light, subtest)
  @feedback.report_subresult(subresult)
  subresult
end

#unneededObject



43
44
45
# File 'lib/ciat/test.rb', line 43

def unneeded
  CIAT::TrafficLight::UNNEEDED
end

#unsetObject



47
48
49
# File 'lib/ciat/test.rb', line 47

def unset
  CIAT::TrafficLight::UNSET
end