# encoding: UTF-8 require 'test_helper' class TestColorer < Pizzazz::TestCase def test_that_it_colors_hashes colored = Pizzazz.ify({:foo => 'bar'}) assert_equal colored, %Q{{ "foo": "bar" }} end def test_tabs colored = Pizzazz.ify({:foo => 'bar'}, tab: '||||') assert_equal colored, %Q{{ ||||"foo": "bar" }} end def test_prefix colored = Pizzazz.ify({:foo => 'bar'}, prefix: '**') assert_equal colored, %Q{**{ ** "foo": "bar" **}} end def test_omit_root_container colored = Pizzazz.ify({:foo => 'bar'}, omit_root_container: true) assert_equal colored, %Q{"foo": "bar"} colored = Pizzazz.ify([1, 2], omit_root_container: true) assert_equal colored, %Q{1,\n2} end def test_that_it_truncates_arrays colored = Pizzazz.ify({:numbers => [1, 2, 3]}, :array_limit => 2) assert_equal colored, %Q{{ \"numbers\": [ 1, 2, … ] }} colored = Pizzazz.ify({:numbers => [1, 2, 3]}, :array_limit => 1, :array_omission => 'hello') assert_equal colored, %Q{{ \"numbers\": [ 1, hello ] }} end def test_that_it_truncates_values colored = Pizzazz.ify({:wooden => 'baseball bat'}, :value_limit => 5) assert_equal colored, %Q{{ "wooden": "base…" }} colored = Pizzazz.ify({:wooden => 'baseball bat'}, :value_limit => 9, :value_omission => '!') assert_equal colored, %Q{{ "wooden": "baseball!" }} end end