Created
November 18, 2019 06:01
-
-
Save woahdae/6559f62fc616047ffc6e15b29af8d82e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class CategoryTree < Struct.new(:json) | |
def inspect | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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