Class: DecisionAgent::Testing::TestScenario
- Inherits:
-
Object
- Object
- DecisionAgent::Testing::TestScenario
- Defined in:
- lib/decision_agent/testing/test_scenario.rb
Overview
Represents a single test scenario with context and expected results
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#expected_confidence ⇒ Object
readonly
Returns the value of attribute expected_confidence.
-
#expected_decision ⇒ Object
readonly
Returns the value of attribute expected_decision.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #expected_result? ⇒ Boolean
-
#initialize(id:, context:, expected_decision: nil, expected_confidence: nil, metadata: {}) ⇒ TestScenario
constructor
A new instance of TestScenario.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, context:, expected_decision: nil, expected_confidence: nil, metadata: {}) ⇒ TestScenario
Returns a new instance of TestScenario.
9 10 11 12 13 14 15 16 17 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 9 def initialize(id:, context:, expected_decision: nil, expected_confidence: nil, metadata: {}) @id = id.to_s.freeze @context = context.is_a?(Hash) ? context.freeze : context @expected_decision = expected_decision&.to_s&.freeze @expected_confidence = expected_confidence&.to_f if expected_confidence @metadata = .is_a?(Hash) ? .freeze : freeze end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 7 def context @context end |
#expected_confidence ⇒ Object (readonly)
Returns the value of attribute expected_confidence.
7 8 9 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 7 def expected_confidence @expected_confidence end |
#expected_decision ⇒ Object (readonly)
Returns the value of attribute expected_decision.
7 8 9 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 7 def expected_decision @expected_decision end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 7 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 7 def @metadata end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 33 def ==(other) other.is_a?(TestScenario) && @id == other.id && @context == other.context && @expected_decision == other.expected_decision && (@expected_confidence.nil? || other.expected_confidence.nil? || (@expected_confidence - other.expected_confidence).abs < 0.0001) && @metadata == other. end |
#expected_result? ⇒ Boolean
29 30 31 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 29 def expected_result? !@expected_decision.nil? end |
#to_h ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/decision_agent/testing/test_scenario.rb', line 19 def to_h { id: @id, context: @context, expected_decision: @expected_decision, expected_confidence: @expected_confidence, metadata: @metadata } end |