mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Move value enumeration to another type
This commit is contained in:
parent
0fce18a610
commit
cc3392022e
2 changed files with 20 additions and 2 deletions
|
@ -62,8 +62,8 @@ module Spectator::Formatting
|
|||
io.puts
|
||||
indent do
|
||||
@result.expectations.each_unsatisfied do |expectation|
|
||||
expectation.values.each do |key, value|
|
||||
line(io, MatchDataValuePair.new(key, value))
|
||||
MatchDataValues.new(expectation.values).each do |pair|
|
||||
line(io, Color.failure(pair))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
18
src/spectator/formatting/match_data_values.cr
Normal file
18
src/spectator/formatting/match_data_values.cr
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Spectator::Formatting
|
||||
# Produces a `MatchDataValuePair` for each key-value pair
|
||||
# from `Spectator::Matchers::MatchData#values`.
|
||||
private struct MatchDataValues(T)
|
||||
include Enumerable(MatchDataValuePair)
|
||||
|
||||
# Creates the values mapper.
|
||||
def initialize(@values : T)
|
||||
end
|
||||
|
||||
# Yields pairs that can be printed to output.
|
||||
def each
|
||||
@values.each do |key, value|
|
||||
yield MatchDataValuePair.new(key, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue