Class: QaServer::ScenarioLogger
- Inherits:
-
Object
- Object
- QaServer::ScenarioLogger
- Defined in:
- app/loggers/qa_server/scenario_logger.rb
Constant Summary collapse
- PASS =
ScenarioValidator::PASS
- FAIL =
ScenarioValidator::FAIL
- UNKNOWN =
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(authority_name:, validation_type: '', status:, subauth: '', service: '', action: '', url: '', error_message: '', expected: nil, actual: nil, target: nil) ⇒ 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.
10 11 12 13 14 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 10 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.
4 5 6 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 4 def failure_count @failure_count end |
#test_count ⇒ Object (readonly)
Returns the value of attribute test_count.
4 5 6 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 4 def test_count @test_count end |
Instance Method Details
#add(authority_name:, validation_type: '', status:, subauth: '', service: '', action: '', url: '', error_message: '', expected: nil, actual: nil, target: nil) ⇒ Object
Add a scenario to the log
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 28 def add(authority_name:, validation_type: '', status:, subauth: '', service: '', action: '', url: '', error_message: '', expected: nil, actual: nil, target: nil) @test_count += 1 case status when PASS status_label = '√' when UNKNOWN status_label = '?' @failure_count += 1 when FAIL status_label = 'X' @failure_count += 1 end @log << { type: validation_type, status: status, status_label: status_label, authority_name: , subauthority_name: subauth, service: service, action: action, url: url, expected: expected, actual: actual, target: target, err_message: } end |
#append(other) ⇒ Object
Append a log to this log.
61 62 63 64 65 66 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 61 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.
55 56 57 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 55 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.
69 70 71 72 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 69 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.
80 81 82 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 80 def size to_a.size end |
#to_a ⇒ Object
Returns the scenario test results data as an array.
75 76 77 |
# File 'app/loggers/qa_server/scenario_logger.rb', line 75 def to_a @log end |