mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Create a type to output a key-value pair
This commit is contained in:
parent
4e3290ebfe
commit
1610d6ebe3
2 changed files with 16 additions and 5 deletions
|
@ -63,11 +63,7 @@ module Spectator::Formatters
|
||||||
indent do
|
indent do
|
||||||
@result.expectations.each_unsatisfied do |expectation|
|
@result.expectations.each_unsatisfied do |expectation|
|
||||||
expectation.values.each do |key, value|
|
expectation.values.each do |key, value|
|
||||||
line(io) do
|
line(io) { io << MatchDataValuePair.new(key, value) }
|
||||||
io << key
|
|
||||||
io << ": "
|
|
||||||
io << value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
15
src/spectator/formatters/match_data_value_pair.cr
Normal file
15
src/spectator/formatters/match_data_value_pair.cr
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
module Spectator::Formatters
|
||||||
|
# A single key-value pair from the `Spectator::Matchers::MatchData#value` method.
|
||||||
|
private struct MatchDataValuePair(T)
|
||||||
|
# Creates the pair formatter.
|
||||||
|
def initialize(@key : Symbol, @value : T)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Appends the pair to the output.
|
||||||
|
def to_s(io)
|
||||||
|
io << @key
|
||||||
|
io << ": "
|
||||||
|
io << @value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue