mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Update formatting to use Tuple
This commit is contained in:
parent
9dc5a999d1
commit
353e5f6886
3 changed files with 9 additions and 9 deletions
|
@ -53,7 +53,7 @@ module Spectator::Formatting
|
|||
# Produces a list of unsatisfied expectations and their values.
|
||||
private def unsatisfied_expectations(indent)
|
||||
@result.expectations.each_unsatisfied do |expectation|
|
||||
indent.line(Color.failure(LabeledText.new("Failure", expectation.actual_message)))
|
||||
indent.line(Color.failure(LabeledText.new("Failure", expectation.failure_message)))
|
||||
indent.line
|
||||
indent.increase do
|
||||
matcher_values(indent, expectation)
|
||||
|
|
|
@ -19,7 +19,7 @@ module Spectator::Formatting
|
|||
private def content(xml)
|
||||
super
|
||||
@result.expectations.each_unsatisfied do |expectation|
|
||||
xml.element("failure", message: expectation.actual_message) do
|
||||
xml.element("failure", message: expectation.failure_message) do
|
||||
expectation_values(expectation.values, xml)
|
||||
end
|
||||
end
|
||||
|
@ -28,8 +28,8 @@ module Spectator::Formatting
|
|||
# Adds the expectation values to the failure block.
|
||||
private def expectation_values(labeled_values, xml)
|
||||
labeled_values.each do |entry|
|
||||
label = entry.label
|
||||
value = entry.value
|
||||
label = entry.first
|
||||
value = entry.last
|
||||
xml.text("#{label}: #{value}\n")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,22 +2,22 @@ module Spectator::Formatting
|
|||
# Produces a `MatchDataValuePair` for each key-value pair
|
||||
# from `Spectator::Matchers::MatchData#values`.
|
||||
private struct MatchDataValues
|
||||
include Enumerable(MatchDataValuePair)
|
||||
include Enumerable(Tuple(Symbol, String))
|
||||
|
||||
@max_key_length : Int32
|
||||
|
||||
# Creates the values mapper.
|
||||
def initialize(@values : Array(Spectator::Matchers::MatchDataLabeledValue))
|
||||
@max_key_length = @values.map(&.label.to_s.size).max
|
||||
def initialize(@values : Array(Tuple(Symbol, String)))
|
||||
@max_key_length = @values.map(&.first.to_s.size).max
|
||||
end
|
||||
|
||||
# Yields pairs that can be printed to output.
|
||||
def each
|
||||
@values.each do |labeled_value|
|
||||
key = labeled_value.label
|
||||
key = labeled_value.first
|
||||
key_length = key.to_s.size
|
||||
padding = @max_key_length - key_length
|
||||
yield MatchDataValuePair.new(key, labeled_value.value, padding)
|
||||
yield MatchDataValuePair.new(key, labeled_value.last, padding)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue