mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Move message line inside content
This allows for multiple message lines for multiple expectations.
This commit is contained in:
parent
238dc38a36
commit
2c5da0c345
1 changed files with 19 additions and 26 deletions
|
@ -27,7 +27,6 @@ module Spectator::Formatting
|
||||||
indent.increase do
|
indent.increase do
|
||||||
title(indent)
|
title(indent)
|
||||||
indent.increase(inner_indent) do
|
indent.increase(inner_indent) do
|
||||||
message(indent)
|
|
||||||
content(indent)
|
content(indent)
|
||||||
source(indent)
|
source(indent)
|
||||||
end
|
end
|
||||||
|
@ -43,34 +42,23 @@ module Spectator::Formatting
|
||||||
indent.line(NumberedItem.new(@index, @result.example))
|
indent.line(NumberedItem.new(@index, @result.example))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces the message line of the failure block.
|
|
||||||
# The line takes the form:
|
|
||||||
# ```text
|
|
||||||
# Failure: Error message
|
|
||||||
# ```
|
|
||||||
# The indentation of this line starts directly under
|
|
||||||
# the example name from the title line.
|
|
||||||
private def message(indent)
|
|
||||||
indent.line(FailureMessage.color(@result))
|
|
||||||
end
|
|
||||||
|
|
||||||
# Produces the main content of the failure block.
|
# Produces the main content of the failure block.
|
||||||
# Any failed expectations are displayed,
|
# Any failed expectations are displayed,
|
||||||
# then an error stacktrace if an error occurred.
|
# then an error stacktrace if an error occurred.
|
||||||
private def content(indent)
|
private def content(indent)
|
||||||
indent.line
|
unsatisfied_expectations(indent)
|
||||||
indent.increase do
|
error_stacktrace(indent) if @result.is_a?(ErroredResult)
|
||||||
unsatisfied_expectations(indent)
|
|
||||||
error_stacktrace(indent) if @result.is_a?(ErroredResult)
|
|
||||||
end
|
|
||||||
indent.line
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces a list of unsatisfied expectations and their values.
|
# Produces a list of unsatisfied expectations and their values.
|
||||||
private def unsatisfied_expectations(indent)
|
private def unsatisfied_expectations(indent)
|
||||||
@result.expectations.each_unsatisfied do |expectation|
|
@result.expectations.each_unsatisfied do |expectation|
|
||||||
# TODO: Failure message for this expectation.
|
indent.line(FailureMessage.color(@result))
|
||||||
matcher_values(indent, expectation)
|
indent.line
|
||||||
|
indent.increase do
|
||||||
|
matcher_values(indent, expectation)
|
||||||
|
end
|
||||||
|
indent.line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,15 +72,20 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Produces the stack trace for an errored result.
|
# Produces the stack trace for an errored result.
|
||||||
private def error_stacktrace(indent)
|
private def error_stacktrace(indent)
|
||||||
|
indent.line(FailureMessage.color(@result))
|
||||||
|
indent.line
|
||||||
error = @result.error
|
error = @result.error
|
||||||
loop do
|
indent.increase do
|
||||||
display_error(indent, error)
|
loop do
|
||||||
if (next_error = error.cause)
|
display_error(indent, error)
|
||||||
error = next_error
|
if (next_error = error.cause)
|
||||||
else
|
error = next_error
|
||||||
break
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
indent.line
|
||||||
end
|
end
|
||||||
|
|
||||||
# Display a single error and its stacktrace.
|
# Display a single error and its stacktrace.
|
||||||
|
|
Loading…
Reference in a new issue