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,31 +58,36 @@ module Spectator::Formatting
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces the main content of the failure block.
|
# 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)
|
private def content(io)
|
||||||
io.puts
|
io.puts
|
||||||
if(@result.is_a?(ErroredResult))
|
indent do
|
||||||
stack_trace(io)
|
unsatisfied_expectations(io)
|
||||||
else
|
error_stacktrace(io) if @result.is_a?(ErroredResult)
|
||||||
values(io)
|
|
||||||
end
|
end
|
||||||
io.puts
|
io.puts
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces the values list of the failure block.
|
# Produces a list of unsatisfied expectations and their values.
|
||||||
private def values(io)
|
private def unsatisfied_expectations(io)
|
||||||
indent do
|
|
||||||
@result.expectations.each_unsatisfied do |expectation|
|
@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|
|
MatchDataValues.new(expectation.values).each do |pair|
|
||||||
|
# TODO: Not all expectations will be failures (color green and red).
|
||||||
line(io, Color.failure(pair))
|
line(io, Color.failure(pair))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Produces the stack trace for an errored result.
|
# Produces the stack trace for an errored result.
|
||||||
private def stack_trace(io)
|
private def error_stacktrace(io)
|
||||||
error = @result.error
|
error = @result.error
|
||||||
indent do
|
|
||||||
loop do
|
loop do
|
||||||
display_error(io, error)
|
display_error(io, error)
|
||||||
if (next_error = error.cause)
|
if (next_error = error.cause)
|
||||||
|
@ -92,7 +97,6 @@ module Spectator::Formatting
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Display a single error and its stacktrace.
|
# Display a single error and its stacktrace.
|
||||||
private def display_error(io, error) : Nil
|
private def display_error(io, error) : Nil
|
||||||
|
|
Loading…
Reference in a new issue