mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Show error block for forced failure - fail
Fixes https://gitlab.com/arctic-fox/spectator/-/issues/78
This commit is contained in:
parent
027521a7bc
commit
9d6d8de72f
2 changed files with 13 additions and 3 deletions
|
@ -18,7 +18,10 @@ module Spectator::Formatting::Components
|
||||||
|
|
||||||
# Prefix for the second line of the block.
|
# Prefix for the second line of the block.
|
||||||
private def subtitle_label
|
private def subtitle_label
|
||||||
"Error: ".colorize(:red)
|
case @error
|
||||||
|
when ExampleFailed then "Failed: "
|
||||||
|
else "Error: "
|
||||||
|
end.colorize(:red)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Display error information.
|
# Display error information.
|
||||||
|
|
|
@ -63,10 +63,17 @@ module Spectator::Formatting
|
||||||
# Displays one or more blocks for a failed example.
|
# Displays one or more blocks for a failed example.
|
||||||
# Each block is a failed expectation or error raised in the example.
|
# Each block is a failed expectation or error raised in the example.
|
||||||
private def dump_failed_example(example, index)
|
private def dump_failed_example(example, index)
|
||||||
error = example.result.as?(ErrorResult).try(&.error)
|
# Retrieve the ultimate reason for failing.
|
||||||
|
error = example.result.as?(FailResult).try(&.error)
|
||||||
|
|
||||||
|
# Prevent displaying duplicated output from expectation.
|
||||||
|
# Display `ExampleFailed` but not `ExpectationFailed`.
|
||||||
|
error = nil if error.responds_to?(:expectation)
|
||||||
|
|
||||||
|
# Gather all failed expectations.
|
||||||
failed_expectations = example.result.expectations.select(&.failed?)
|
failed_expectations = example.result.expectations.select(&.failed?)
|
||||||
block_count = failed_expectations.size
|
block_count = failed_expectations.size
|
||||||
block_count += 1 if error
|
block_count += 1 if error # Add an extra block for final error if it's significant.
|
||||||
|
|
||||||
# Don't use sub-index if there was only one problem.
|
# Don't use sub-index if there was only one problem.
|
||||||
if block_count == 1
|
if block_count == 1
|
||||||
|
|
Loading…
Reference in a new issue