Class: CemAcpt::TestRunner::TestResults::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/cem_acpt/test_runner/test_results.rb

Overview

Class that manages test results

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil, instance_names_ips = nil) ⇒ Results

Returns a new instance of Results.



17
18
19
20
21
# File 'lib/cem_acpt/test_runner/test_results.rb', line 17

def initialize(config = nil, instance_names_ips = nil)
  @results_queue = Queue.new
  @config = config
  @instance_names_ips = instance_names_ips
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **kwargs, &block) ⇒ Object



51
52
53
# File 'lib/cem_acpt/test_runner/test_results.rb', line 51

def method_missing(method_name, *args, **kwargs, &block)
  @results_queue.send(method_name, *args, **kwargs, &block)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



15
16
17
# File 'lib/cem_acpt/test_runner/test_results.rb', line 15

def config
  @config
end

#instance_names_ipsObject

Returns the value of attribute instance_names_ips.



15
16
17
# File 'lib/cem_acpt/test_runner/test_results.rb', line 15

def instance_names_ips
  @instance_names_ips
end

Instance Method Details

#<<(result) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/cem_acpt/test_runner/test_results.rb', line 30

def <<(result)
  case result
  when CemAcpt::Goss::Api::ActionResponse, CemAcpt::Bolt::SummaryResults
    @results_queue << TestActionResult.new(result, new_formatter(result))
  when StandardError
    @results_queue << TestErrorActionResult.new(result, new_formatter(result))
  else
    raise ArgumentError, "result must be a CemAcpt::Goss::Api::ActionResponse, CemAcpt::Bolt::SummaryResults, or StandardError, got #{result.class}"
  end
end

#combine(other) ⇒ Object



23
24
25
26
27
28
# File 'lib/cem_acpt/test_runner/test_results.rb', line 23

def combine(other)
  new_res_queue_data = (to_a + other.to_a).compact.uniq
  @results_queue = Queue.new(new_res_queue_data)

  self
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/cem_acpt/test_runner/test_results.rb', line 55

def respond_to_missing?(method_name, include_private = false)
  @results_queue.respond_to?(method_name, include_private) || super
end

#to_aObject



41
42
43
44
45
46
47
48
49
# File 'lib/cem_acpt/test_runner/test_results.rb', line 41

def to_a
  results = []
  @results_queue.close unless @results_queue.closed?
  while (r = @results_queue.pop)
    results << r
  end
  @results_queue = Queue.new(results)
  results
end