lib/option_value.rb in markdown_exec-2.3.0 vs lib/option_value.rb in markdown_exec-2.4.0

- old
+ new

@@ -14,11 +14,11 @@ # Formats the value for use in a hash. def self.for_hash(value, default = nil) return default if value.nil? case value - when String, Integer + when String, Integer, Array, Hash value when TrueClass, FalseClass value ? true : false when ->(v) { v.respond_to?(:empty?) && v.empty? } default @@ -62,11 +62,15 @@ def test_for_hash_with_boolean assert_equal true, MarkdownExec::OptionValue.for_hash(true) assert_equal false, MarkdownExec::OptionValue.for_hash(false) end - def test_for_hash_with_empty_value - assert_equal 'default', MarkdownExec::OptionValue.for_hash([], 'default') + def test_for_hash_with_empty_array + assert_equal [], MarkdownExec::OptionValue.for_hash([], 'default') + end + + def test_for_hash_with_empty_hash + assert_equal({}, MarkdownExec::OptionValue.for_hash({}, 'default')) end def test_for_yaml_with_string assert_equal "'sample'", MarkdownExec::OptionValue.for_yaml('sample') end