Class: Familia::Validation::ValidationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/familia/validation/expectations.rb

Overview

Result of validation with detailed information

Instance Attribute Summary collapse

Instance Method Summary collapse

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_sequenceObject (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

#errorsObject (readonly)

Returns the value of attribute errors.



360
361
362
# File 'lib/familia/validation/expectations.rb', line 360

def errors
  @errors
end

#expectationsObject (readonly)

Returns the value of attribute expectations.



360
361
362
# File 'lib/familia/validation/expectations.rb', line 360

def expectations
  @expectations
end

#warningsObject (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_reportObject



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_messagesObject



379
380
381
# File 'lib/familia/validation/expectations.rb', line 379

def error_messages
  @errors
end

#summaryObject



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

Returns:

  • (Boolean)


375
376
377
# File 'lib/familia/validation/expectations.rb', line 375

def valid?
  @valid == true
end

#validateObject



370
371
372
373
# File 'lib/familia/validation/expectations.rb', line 370

def validate
  @valid = perform_validation
  self
end

#warning_messagesObject



383
384
385
# File 'lib/familia/validation/expectations.rb', line 383

def warning_messages
  @warnings
end