Skip to content

Instantly share code, notes, and snippets.

@woahdae
Created November 18, 2019 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woahdae/6559f62fc616047ffc6e15b29af8d82e to your computer and use it in GitHub Desktop.
Save woahdae/6559f62fc616047ffc6e15b29af8d82e to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
class CategoryTree < Struct.new(:json)
def inspect
end
end
# frozen_string_literal: true
require 'minitest/autorun'
require_relative 'category_tree'
class TreePrinterTest < Minitest::Test
def setup
@category_tree =
CategoryTree.new(
'Garlic' => ['Chesnok Red', 'Ozark'],
'Tomatoes' => {
'Beefsteak' =>
['Galahad', 'Grand Marshall', 'Brandywine'],
'Cherry' =>
['Sun Gold', 'Supersweet 100']
}
)
end
def test_inspect_prints_category_tree
expected = <<~TREE
Garlic
-- Chesnok Red
-- Ozark
Tomatoes
-- Beefsteak
-- -- Galahad
-- -- Grand Marshall
-- -- Brandywine
-- Cherry
-- -- Sun Gold
-- -- Supersweet 100
TREE
assert_equal(expected.strip, @category_tree.inspect)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment