diff options
Diffstat (limited to 'test/test_string_extension.rb')
-rw-r--r-- | test/test_string_extension.rb | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/test/test_string_extension.rb b/test/test_string_extension.rb index 9f87294..125f48e 100644 --- a/test/test_string_extension.rb +++ b/test/test_string_extension.rb @@ -13,7 +13,6 @@ require "highline" require "stringio" require "string_methods" - # FakeString is here just to avoid # using HighLine.colorize_strings # on tests @@ -35,16 +34,19 @@ class TestStringExtension < Minitest::Test include StringMethods def test_Highline_String_is_yaml_serializable - require 'yaml' - unless Gem::Version.new(YAML::VERSION) < Gem::Version.new("2.0.2") - highline_string = HighLine::String.new("Yaml didn't messed with HighLine::String") - yaml_highline_string = highline_string.to_yaml - yaml_loaded_string = YAML.load(yaml_highline_string) - - assert_equal "Yaml didn't messed with HighLine::String", yaml_loaded_string - assert_equal highline_string, yaml_loaded_string - assert_instance_of HighLine::String, yaml_loaded_string - end + require "yaml" + return if Gem::Version.new(YAML::VERSION) < Gem::Version.new("2.0.2") + + highline_string = + HighLine::String.new("Yaml didn't messed with HighLine::String") + yaml_highline_string = highline_string.to_yaml + yaml_loaded_string = + YAML.safe_load(yaml_highline_string, [HighLine::String]) + + assert_equal "Yaml didn't messed with HighLine::String", + yaml_loaded_string + assert_equal highline_string, yaml_loaded_string + assert_instance_of HighLine::String, yaml_loaded_string end def test_highline_string_respond_to_color @@ -63,10 +65,16 @@ class TestStringExtension < Minitest::Test def test_String_includes_StringExtension_when_receives_colorize_strings @include_received = 0 - caller = Proc.new { @include_received += 1 } + caller = proc { @include_received += 1 } ::String.stub :include, caller do HighLine.colorize_strings end assert_equal 1, @include_received end + + def test_respond_to_dynamic_style_methods + string = HighLine::String.new("pirarucu") + assert_respond_to(string, :on_rgb_123456) + assert_respond_to(string, :rgb_abcdef) + end end |