Class: Familia::Validation::ValidationResult
- Inherits:
-
Object
- Object
- Familia::Validation::ValidationResult
- Defined in:
- lib/familia/validation/expectations.rb
Overview
Result of validation with detailed information
Instance Attribute Summary collapse
-
#command_sequence ⇒ Object
readonly
Returns the value of attribute command_sequence.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#expectations ⇒ Object
readonly
Returns the value of attribute expectations.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#detailed_report ⇒ Object
-
#error_messages ⇒ Object
-
#initialize(expectations, command_sequence) ⇒ ValidationResult
constructor
A new instance of ValidationResult.
-
#summary ⇒ Object
-
#valid? ⇒ Boolean
-
#validate ⇒ Object
-
#warning_messages ⇒ Object
Constructor Details
#initialize(expectations, command_sequence) ⇒ ValidationResult
Returns a new instance of ValidationResult.
362 363 364 365 366 367 368 |
# File 'lib/familia/validation/expectations.rb', line 362 def initialize(expectations, command_sequence) @expectations = expectations @command_sequence = command_sequence @errors = [] @warnings = [] @valid = nil end |
Instance Attribute Details
#command_sequence ⇒ Object (readonly)
Returns the value of attribute command_sequence.
360 361 362 |
# File 'lib/familia/validation/expectations.rb', line 360 def command_sequence @command_sequence end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
360 361 362 |
# File 'lib/familia/validation/expectations.rb', line 360 def errors @errors end |
#expectations ⇒ Object (readonly)
Returns the value of attribute expectations.
360 361 362 |
# File 'lib/familia/validation/expectations.rb', line 360 def expectations @expectations end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
360 361 362 |
# File 'lib/familia/validation/expectations.rb', line 360 def warnings @warnings end |
Instance Method Details
#detailed_report ⇒ Object
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/familia/validation/expectations.rb', line 399 def detailed_report report = ["Redis Command Validation Report", "=" * 40] report << "Status: #{valid? ? 'PASS' : 'FAIL'}" report << "" if valid? report << "All expectations matched successfully!" else report << "Validation Errors:" @errors.each_with_index do |error, i| report << " #{i + 1}. #{error}" end end if @warnings.any? report << "" report << "Warnings:" @warnings.each_with_index do |warning, i| report << " #{i + 1}. #{warning}" end end report << "" report << "Summary:" summary.each do |key, value| report << " #{key}: #{value}" end report.join("\n") end |
#error_messages ⇒ Object
379 380 381 |
# File 'lib/familia/validation/expectations.rb', line 379 def @errors end |
#summary ⇒ Object
387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/familia/validation/expectations.rb', line 387 def summary { valid: valid?, expected_commands: @expectations.expected_commands.length, actual_commands: @command_sequence.command_count, expected_transactions: @expectations.transaction_blocks.length, actual_transactions: @command_sequence.transaction_count, errors: @errors.length, warnings: @warnings.length } end |
#valid? ⇒ Boolean
375 376 377 |
# File 'lib/familia/validation/expectations.rb', line 375 def valid? @valid == true end |
#validate ⇒ Object
370 371 372 373 |
# File 'lib/familia/validation/expectations.rb', line 370 def validate @valid = perform_validation self end |
#warning_messages ⇒ Object
383 384 385 |
# File 'lib/familia/validation/expectations.rb', line 383 def @warnings end |