Class: Steep::Expectations::TestResult
- Defined in:
- lib/steep/expectations.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expectation ⇒ Object
readonly
Returns the value of attribute expectation.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #each_diagnostics ⇒ Object
- #empty? ⇒ Boolean
- #expected_diagnostics ⇒ Object
-
#initialize(path:, expectation:, actual:) ⇒ TestResult
constructor
A new instance of TestResult.
- #missing_diagnostics ⇒ Object
- #satisfied? ⇒ Boolean
- #unexpected_diagnostics ⇒ Object
Constructor Details
#initialize(path:, expectation:, actual:) ⇒ TestResult
Returns a new instance of TestResult.
139 140 141 142 143 |
# File 'lib/steep/expectations.rb', line 139 def initialize(path:, expectation:, actual:) @path = path @expectation = expectation @actual = actual end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
137 138 139 |
# File 'lib/steep/expectations.rb', line 137 def actual @actual end |
#expectation ⇒ Object (readonly)
Returns the value of attribute expectation.
136 137 138 |
# File 'lib/steep/expectations.rb', line 136 def expectation @expectation end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
135 136 137 |
# File 'lib/steep/expectations.rb', line 135 def path @path end |
Instance Method Details
#each_diagnostics ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/steep/expectations.rb', line 153 def each_diagnostics if block_given? expected_set = Set.new(expectation) #: Set[Diagnostic] actual_set = Set.new(actual) #: Set[Diagnostic] (expected_set + actual_set).sort_by(&:sort_key).each do |diagnostic| case when expected_set.include?(diagnostic) && actual_set.include?(diagnostic) yield [:expected, diagnostic] when expected_set.include?(diagnostic) yield [:missing, diagnostic] when actual_set.include?(diagnostic) yield [:unexpected, diagnostic] end end else enum_for :each_diagnostics end end |
#empty? ⇒ Boolean
145 146 147 |
# File 'lib/steep/expectations.rb', line 145 def empty? actual.empty? end |
#expected_diagnostics ⇒ Object
173 174 175 |
# File 'lib/steep/expectations.rb', line 173 def expected_diagnostics each_diagnostics.select {|type, _| type == :expected }.map {|_, diag| diag } end |
#missing_diagnostics ⇒ Object
181 182 183 |
# File 'lib/steep/expectations.rb', line 181 def missing_diagnostics each_diagnostics.select {|type, _| type == :missing }.map {|_, diag| diag } end |
#satisfied? ⇒ Boolean
149 150 151 |
# File 'lib/steep/expectations.rb', line 149 def satisfied? unexpected_diagnostics.empty? && missing_diagnostics.empty? end |
#unexpected_diagnostics ⇒ Object
177 178 179 |
# File 'lib/steep/expectations.rb', line 177 def unexpected_diagnostics each_diagnostics.select {|type, _| type == :unexpected }.map {|_, diag| diag } end |