Skip to content

Commit

Permalink
Refactor converting hash with struct
Browse files Browse the repository at this point in the history
Update #503
  • Loading branch information
kachick committed Mar 20, 2024
1 parent 6304ddc commit 9fae027
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions test/many_data/test_snapshots.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,11 @@

# https://github.com/kachick/ruby-ulid/issues/89
class TestSnapshots < Test::Unit::TestCase
toml = PerfectTOML.load_file("#{__dir__}/fixtures/snapshots_2024-01-10_07-59.toml")
EXAMPLES = toml.each_pair.with_object([]) do |(encoded, table), list|
list << Example.new(
string: encoded,
integer: table.fetch('integer'),
timestamp: table.fetch('timestamp'),
randomness: table.fetch('randomness'),
to_time: table.fetch('to_time'),
inspect: table.fetch('inspect'),
uuidv4: table.fetch('uuidv4'),
octets: table.fetch('octets'),
period: nil
)
toml = PerfectTOML.load_file("#{__dir__}/fixtures/snapshots_2024-01-10_07-59.toml", symbolize_names: true)
EXAMPLES = toml.each_pair.to_a.map do |(encoded, table)|
Example.new(**table, string: encoded.id2name, period: nil)
end
raise 'looks like misloading' unless EXAMPLES.size > 1000

def assert_example(ulid, example)
assert_equal(example.string, ulid.to_s)
Expand Down

0 comments on commit 9fae027

Please sign in to comment.