mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Support output of multiple failed expectations
This commit is contained in:
parent
88f0c23a3e
commit
621ddb466f
2 changed files with 10 additions and 5 deletions
|
@ -7,14 +7,12 @@ require "./result_block"
|
||||||
module Spectator::Formatting::Components
|
module Spectator::Formatting::Components
|
||||||
# Displays information about a fail result.
|
# Displays information about a fail result.
|
||||||
struct FailResultBlock < ResultBlock
|
struct FailResultBlock < ResultBlock
|
||||||
@expectation : Expectation
|
|
||||||
@longest_key : Int32
|
@longest_key : Int32
|
||||||
|
|
||||||
# Creates the component.
|
# Creates the component.
|
||||||
def initialize(example : Example, index : Int32, result : FailResult, subindex = 0)
|
def initialize(example : Example, index : Int32, @expectation : Expectation, subindex = 0)
|
||||||
super(example, index, subindex)
|
super(example, index, subindex)
|
||||||
@expectation = result.expectations.find(&.failed?).not_nil!
|
@longest_key = expectation.values.max_of { |(key, _value)| key.to_s.size }
|
||||||
@longest_key = @expectation.values.max_of { |(key, _value)| key.to_s.size }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Content displayed on the second line of the block after the label.
|
# Content displayed on the second line of the block after the label.
|
||||||
|
|
|
@ -41,7 +41,14 @@ module Spectator::Formatting
|
||||||
if result = example.result.as?(ErrorResult)
|
if result = example.result.as?(ErrorResult)
|
||||||
io.puts Components::ErrorResultBlock.new(example, index, result)
|
io.puts Components::ErrorResultBlock.new(example, index, result)
|
||||||
elsif result = example.result.as?(FailResult)
|
elsif result = example.result.as?(FailResult)
|
||||||
io.puts Components::FailResultBlock.new(example, index, result)
|
failed_expectations = result.expectations.select(&.failed?)
|
||||||
|
if failed_expectations.size == 1
|
||||||
|
io.puts Components::FailResultBlock.new(example, index, failed_expectations.first)
|
||||||
|
else
|
||||||
|
failed_expectations.each_with_index(1) do |expectation, subindex|
|
||||||
|
io.puts Components::FailResultBlock.new(example, index, expectation, subindex)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue