Class: AggregateAssertions::FailureGroup
- Inherits:
-
Object
- Object
- AggregateAssertions::FailureGroup
- Defined in:
- lib/aggregate_assertions/failure_group.rb
Overview
This class is used to aggregates the failures/errors for an aggregate block.
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #add_error(error) ⇒ Object
- #error ⇒ Object
-
#initialize(location:, label: nil) ⇒ FailureGroup
constructor
A new instance of FailureGroup.
- #success? ⇒ Boolean
Constructor Details
#initialize(location:, label: nil) ⇒ FailureGroup
Returns a new instance of FailureGroup.
10 11 12 13 14 15 |
# File 'lib/aggregate_assertions/failure_group.rb', line 10 def initialize(location:, label: nil) @location = location @label = label @failures = [] @other_errors = [] end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/aggregate_assertions/failure_group.rb', line 8 def label @label end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
8 9 10 |
# File 'lib/aggregate_assertions/failure_group.rb', line 8 def location @location end |
Instance Method Details
#add_error(error) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/aggregate_assertions/failure_group.rb', line 17 def add_error(error) if error.is_a?(Minitest::Assertion) @failures << error else @other_errors << error end end |
#error ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aggregate_assertions/failure_group.rb', line 25 def error case @failures.size + @other_errors.size when 0 nil when 1 @failures.first || @other_errors.first else group_error end end |
#success? ⇒ Boolean
36 37 38 |
# File 'lib/aggregate_assertions/failure_group.rb', line 36 def success? @failures.empty? && @other_errors.empty? end |