mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
WIP display all expectations
Display the error stacktrace after expectations if the result is an ErroredResult.
This commit is contained in:
parent
66c1dc3bce
commit
f73a51ae0c
1 changed files with 25 additions and 21 deletions
|
@ -58,38 +58,42 @@ module Spectator::Formatting
|
|||
end
|
||||
|
||||
# Produces the main content of the failure block.
|
||||
# Any failed expectations are displayed,
|
||||
# then an error stacktrace if an error occurred.
|
||||
private def content(io)
|
||||
io.puts
|
||||
if(@result.is_a?(ErroredResult))
|
||||
stack_trace(io)
|
||||
else
|
||||
values(io)
|
||||
indent do
|
||||
unsatisfied_expectations(io)
|
||||
error_stacktrace(io) if @result.is_a?(ErroredResult)
|
||||
end
|
||||
io.puts
|
||||
end
|
||||
|
||||
# Produces the values list of the failure block.
|
||||
private def values(io)
|
||||
indent do
|
||||
@result.expectations.each_unsatisfied do |expectation|
|
||||
MatchDataValues.new(expectation.values).each do |pair|
|
||||
line(io, Color.failure(pair))
|
||||
end
|
||||
end
|
||||
# Produces a list of unsatisfied expectations and their values.
|
||||
private def unsatisfied_expectations(io)
|
||||
@result.expectations.each_unsatisfied do |expectation|
|
||||
# TODO: Failure message for this expectation.
|
||||
matcher_values(io, expectation)
|
||||
end
|
||||
end
|
||||
|
||||
# Produces the values list for an expectation
|
||||
private def matcher_values(io, expectation)
|
||||
MatchDataValues.new(expectation.values).each do |pair|
|
||||
# TODO: Not all expectations will be failures (color green and red).
|
||||
line(io, Color.failure(pair))
|
||||
end
|
||||
end
|
||||
|
||||
# Produces the stack trace for an errored result.
|
||||
private def stack_trace(io)
|
||||
private def error_stacktrace(io)
|
||||
error = @result.error
|
||||
indent do
|
||||
loop do
|
||||
display_error(io, error)
|
||||
if (next_error = error.cause)
|
||||
error = next_error
|
||||
else
|
||||
break
|
||||
end
|
||||
loop do
|
||||
display_error(io, error)
|
||||
if (next_error = error.cause)
|
||||
error = next_error
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue