Class: QaServer::ScenarioLogger
- Inherits:
-
Object
- Object
- QaServer::ScenarioLogger
- Includes:
- Enumerable
- Defined in:
- app/loggers/qa_server/scenario_logger.rb
Constant Summary collapse
- PASS =
QaServer::ScenarioValidator::PASS
- FAIL =
QaServer::ScenarioValidator::FAIL
- UNKNOWN =
QaServer::ScenarioValidator::UNKNOWN
Instance Attribute Summary collapse
-
#failure_count ⇒ Object
readonly
Returns the value of attribute failure_count.
-
#test_count ⇒ Object
readonly
Returns the value of attribute test_count.
Instance Method Summary collapse
-
#add(status_info) ⇒ Object
Add a scenario to the log.
-
#append(other) ⇒ Object
Append a log to this log.
-
#delete_passing ⇒ Object
Delete from the log any tests that passed.
-
#filter(type: nil) ⇒ Object
Selected scenario test results data as an array limited to the specified type or all scenarios if type is nil.
-
#initialize(test_count = 0, failure_count = 0) ⇒ ScenarioLogger
constructor
A new instance of ScenarioLogger.
-
#size ⇒ Object
The number of scenarios recorded in the log.
-
#to_a ⇒ Object
The scenario test results data as an array.
Constructor Details
#initialize(test_count = 0, failure_count = 0) ⇒ ScenarioLogger
Returns a new instance of ScenarioLogger.
16 17 18 19 20 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 16 def initialize(test_count = 0, failure_count = 0) @log = [] @test_count = test_count @failure_count = failure_count end |
Instance Attribute Details
#failure_count ⇒ Object (readonly)
Returns the value of attribute failure_count.
10 11 12 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 10 def failure_count @failure_count end |
#test_count ⇒ Object (readonly)
Returns the value of attribute test_count.
10 11 12 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 10 def test_count @test_count end |
Instance Method Details
#add(status_info) ⇒ Object
Add a scenario to the log
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 37 def add(status_info) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength @test_count += 1 @failure_count += 1 unless status_info[:status] == PASS @log << { type: status_info[:validation_type] || '', status: status_info[:status] || '', authority_name: status_info[:authority_name] || '', subauthority_name: status_info[:subauth] || '', service: status_info[:service] || '', action: status_info[:action] || '', url: status_info[:url] || '', expected: status_info[:expected] || nil, actual: status_info[:actual] || nil, target: status_info[:target] || nil, err_message: status_info[:error_message] || '', request_run_time: status_info[:request_run_time] || nil, normalization_run_time: status_info[:normalization_run_time] || nil } end |
#append(other) ⇒ Object
Append a log to this log.
62 63 64 65 66 67 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 62 def append(other) return unless other.present? @log += other.to_a @test_count += other.test_count @failure_count += other.failure_count end |
#delete_passing ⇒ Object
Delete from the log any tests that passed.
56 57 58 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 56 def delete_passing @log.delete_if { |entry| entry[:status] == PASS } end |
#filter(type: nil) ⇒ Object
Returns selected scenario test results data as an array limited to the specified type or all scenarios if type is nil.
70 71 72 73 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 70 def filter(type: nil) return @log if type.blank? @log.select { |entry| entry[:type] == type } end |
#size ⇒ Object
Returns the number of scenarios recorded in the log.
8 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 8 delegate :size, :each, to: :@log |
#to_a ⇒ Object
Returns the scenario test results data as an array.
76 77 78 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 76 def to_a @log end |