diff options
Diffstat (limited to 'test/psych')
-rw-r--r-- | test/psych/helper.rb | 6 | ||||
-rw-r--r-- | test/psych/test_array.rb | 16 | ||||
-rw-r--r-- | test/psych/test_coder.rb | 6 | ||||
-rw-r--r-- | test/psych/test_date_time.rb | 20 | ||||
-rw-r--r-- | test/psych/test_encoding.rb | 11 | ||||
-rw-r--r-- | test/psych/test_hash.rb | 64 | ||||
-rw-r--r-- | test/psych/test_merge_keys.rb | 2 | ||||
-rw-r--r-- | test/psych/test_numeric.rb | 9 | ||||
-rw-r--r-- | test/psych/test_object.rb | 13 | ||||
-rw-r--r-- | test/psych/test_object_references.rb | 8 | ||||
-rw-r--r-- | test/psych/test_parser.rb | 31 | ||||
-rw-r--r-- | test/psych/test_psych.rb | 33 | ||||
-rw-r--r-- | test/psych/test_safe_load.rb | 31 | ||||
-rw-r--r-- | test/psych/test_scalar_scanner.rb | 2 | ||||
-rw-r--r-- | test/psych/test_set.rb | 7 | ||||
-rw-r--r-- | test/psych/test_string.rb | 12 | ||||
-rw-r--r-- | test/psych/test_yaml.rb | 34 | ||||
-rw-r--r-- | test/psych/visitors/test_emitter.rb | 16 | ||||
-rw-r--r-- | test/psych/visitors/test_to_ruby.rb | 2 | ||||
-rw-r--r-- | test/psych/visitors/test_yaml_tree.rb | 8 |
20 files changed, 254 insertions, 77 deletions
diff --git a/test/psych/helper.rb b/test/psych/helper.rb index 0643139d8c..4e82887c6d 100644 --- a/test/psych/helper.rb +++ b/test/psych/helper.rb @@ -51,7 +51,7 @@ module Psych :UseVersion => true, :UseHeader => true, :SortKeys => true ) )) - rescue Psych::DisallowedClass, Psych::BadAlias + rescue Psych::DisallowedClass, Psych::BadAlias, Psych::AliasesNotEnabled assert_to_yaml obj, yaml, :unsafe_load end @@ -61,7 +61,7 @@ module Psych def assert_parse_only( obj, yaml ) begin assert_equal obj, Psych::load( yaml ) - rescue Psych::DisallowedClass, Psych::BadAlias + rescue Psych::DisallowedClass, Psych::BadAlias, Psych::AliasesNotEnabled assert_equal obj, Psych::unsafe_load( yaml ) end assert_equal obj, Psych::parse( yaml ).transform @@ -79,7 +79,7 @@ module Psych assert_equal(obj, Psych.load(v.tree.yaml)) assert_equal(obj, Psych::load(Psych.dump(obj))) assert_equal(obj, Psych::load(obj.to_yaml)) - rescue Psych::DisallowedClass, Psych::BadAlias + rescue Psych::DisallowedClass, Psych::BadAlias, Psych::AliasesNotEnabled assert_equal(obj, Psych.unsafe_load(v.tree.yaml)) assert_equal(obj, Psych::unsafe_load(Psych.dump(obj))) assert_equal(obj, Psych::unsafe_load(obj.to_yaml)) diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb index 28b76da785..0dc82439d4 100644 --- a/test/psych/test_array.rb +++ b/test/psych/test_array.rb @@ -57,6 +57,22 @@ module Psych assert_cycle(@list) end + def test_recursive_array + @list << @list + + loaded = Psych.load(Psych.dump(@list), aliases: true) + + assert_same loaded, loaded.last + end + + def test_recursive_array_uses_alias + @list << @list + + assert_raise(AliasesNotEnabled) do + Psych.load(Psych.dump(@list), aliases: false) + end + end + def test_cycle assert_cycle(@list) end diff --git a/test/psych/test_coder.rb b/test/psych/test_coder.rb index b2be0a4109..a6f5ad7f36 100644 --- a/test/psych/test_coder.rb +++ b/test/psych/test_coder.rb @@ -220,6 +220,8 @@ module Psych end def test_coder_style_map_any + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + foo = Psych.dump CustomEncode.new \ map: {a: 1, b: 2}, style: Psych::Nodes::Mapping::ANY, @@ -228,6 +230,8 @@ module Psych end def test_coder_style_map_block + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + foo = Psych.dump CustomEncode.new \ map: {a: 1, b: 2}, style: Psych::Nodes::Mapping::BLOCK, @@ -236,6 +240,8 @@ module Psych end def test_coder_style_map_flow + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + foo = Psych.dump CustomEncode.new \ map: { a: 1, b: 2 }, style: Psych::Nodes::Mapping::FLOW, diff --git a/test/psych/test_date_time.rb b/test/psych/test_date_time.rb index 6f1e8b509e..3379bd24bf 100644 --- a/test/psych/test_date_time.rb +++ b/test/psych/test_date_time.rb @@ -44,6 +44,26 @@ module Psych assert_match(/12:00:00-05:00/, cycled.last.to_s) end + def test_julian_date + d = Date.new(1582, 10, 4, Date::GREGORIAN) + assert_cycle d + end + + def test_proleptic_gregorian_date + d = Date.new(1582, 10, 14, Date::GREGORIAN) + assert_cycle d + end + + def test_julian_datetime + dt = DateTime.new(1582, 10, 4, 23, 58, 59, 0, Date::GREGORIAN) + assert_cycle dt + end + + def test_proleptic_gregorian_datetime + dt = DateTime.new(1582, 10, 14, 23, 58, 59, 0, Date::GREGORIAN) + assert_cycle dt + end + def test_invalid_date assert_cycle "2013-10-31T10:40:07-000000000000033" end diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb index e5831c9045..1867d59ea6 100644 --- a/test/psych/test_encoding.rb +++ b/test/psych/test_encoding.rb @@ -13,13 +13,13 @@ module Psych (Handler.instance_methods(true) - Object.instance_methods).each do |m| - class_eval %{ + class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{m} *args @strings += args.flatten.find_all { |a| String === a } end - } + RUBY end end @@ -119,6 +119,8 @@ module Psych end def test_emit_alias + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @emitter.start_stream Psych::Parser::UTF8 @emitter.start_document [], [], true e = assert_raise(RuntimeError) do @@ -151,6 +153,7 @@ module Psych @emitter.end_mapping @emitter.end_document false @emitter.end_stream + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ @parser.parse @buffer.string assert_encodings @utf8, @handler.strings @@ -170,6 +173,7 @@ module Psych @emitter.end_sequence @emitter.end_document false @emitter.end_stream + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ @parser.parse @buffer.string assert_encodings @utf8, @handler.strings @@ -187,6 +191,7 @@ module Psych @emitter.scalar 'foo', nil, nil, true, false, Nodes::Scalar::ANY @emitter.end_document false @emitter.end_stream + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ @parser.parse @buffer.string assert_encodings @utf8, @handler.strings @@ -263,6 +268,8 @@ module Psych end def test_dump_non_ascii_string_to_file + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + Tempfile.create(['utf8', 'yml'], :encoding => 'UTF-8') do |t| h = {'one' => 'いち'} Psych.dump(h, t) diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index 5374781339..31eba8580b 100644 --- a/test/psych/test_hash.rb +++ b/test/psych/test_hash.rb @@ -102,26 +102,66 @@ module Psych end def test_ref_append - hash = Psych.unsafe_load(<<-eoyml) ---- -foo: &foo - hello: world -bar: - <<: *foo -eoyml + hash = Psych.unsafe_load(<<~eoyml) + --- + foo: &foo + hello: world + bar: + <<: *foo + eoyml assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash) end + def test_anchor_reuse + hash = Psych.unsafe_load(<<~eoyml) + --- + foo: &foo + hello: world + bar: *foo + eoyml + assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash) + assert_same(hash.fetch("foo"), hash.fetch("bar")) + end + + def test_raises_if_anchor_not_defined + assert_raise(Psych::AnchorNotDefined) do + Psych.unsafe_load(<<~eoyml) + --- + foo: &foo + hello: world + bar: *not_foo + eoyml + end + end + + def test_recursive_hash + h = { } + h["recursive_reference"] = h + + loaded = Psych.load(Psych.dump(h), aliases: true) + + assert_same loaded, loaded.fetch("recursive_reference") + end + + def test_recursive_hash_uses_alias + h = { } + h["recursive_reference"] = h + + assert_raise(AliasesNotEnabled) do + Psych.load(Psych.dump(h), aliases: false) + end + end + def test_key_deduplication unless String.method_defined?(:-@) && (-("a" * 20)).equal?((-("a" * 20))) pend "This Ruby implementation doesn't support string deduplication" end - hashes = Psych.load(<<-eoyml) ---- -- unique_identifier: 1 -- unique_identifier: 2 -eoyml + hashes = Psych.load(<<~eoyml) + --- + - unique_identifier: 1 + - unique_identifier: 2 + eoyml assert_same hashes[0].keys.first, hashes[1].keys.first end diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb index dcf4f1fce3..2f55a1ed8e 100644 --- a/test/psych/test_merge_keys.rb +++ b/test/psych/test_merge_keys.rb @@ -117,7 +117,7 @@ development: bar: << : *foo eoyml - exp = assert_raise(Psych::BadAlias) { Psych.load yaml } + exp = assert_raise(Psych::AnchorNotDefined) { Psych.load(yaml, aliases: true) } assert_match 'foo', exp.message end diff --git a/test/psych/test_numeric.rb b/test/psych/test_numeric.rb index 9c75c016cd..4c012e4562 100644 --- a/test/psych/test_numeric.rb +++ b/test/psych/test_numeric.rb @@ -1,6 +1,9 @@ # frozen_string_literal: true require_relative 'helper' -require 'bigdecimal' +begin + require 'bigdecimal' +rescue LoadError +end module Psych ### @@ -29,13 +32,13 @@ module Psych def test_big_decimal_tag decimal = BigDecimal("12.34") assert_match "!ruby/object:BigDecimal", Psych.dump(decimal) - end + end if defined?(BigDecimal) def test_big_decimal_round_trip decimal = BigDecimal("12.34") $DEBUG = false assert_cycle decimal - end + end if defined?(BigDecimal) def test_does_not_attempt_numeric str = Psych.load('--- 4 roses') diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb index 0faf6b244d..21c27794ea 100644 --- a/test/psych/test_object.rb +++ b/test/psych/test_object.rb @@ -36,10 +36,19 @@ module Psych def test_cyclic_references foo = Foo.new(nil) foo.parent = foo - loaded = Psych.unsafe_load Psych.dump foo + loaded = Psych.load(Psych.dump(foo), permitted_classes: [Foo], aliases: true) assert_instance_of(Foo, loaded) - assert_equal loaded, loaded.parent + assert_same loaded, loaded.parent + end + + def test_cyclic_reference_uses_alias + foo = Foo.new(nil) + foo.parent = foo + + assert_raise(AliasesNotEnabled) do + Psych.load(Psych.dump(foo), permitted_classes: [Foo], aliases: false) + end end end end diff --git a/test/psych/test_object_references.rb b/test/psych/test_object_references.rb index 269d72242e..86bb9034b9 100644 --- a/test/psych/test_object_references.rb +++ b/test/psych/test_object_references.rb @@ -39,7 +39,7 @@ module Psych rescue Psych::DisallowedClass data = Psych.unsafe_load yml end - assert_equal data.first.object_id, data.last.object_id + assert_same data.first, data.last end def test_float_references @@ -49,7 +49,7 @@ module Psych - *name eoyml assert_equal data.first, data.last - assert_equal data.first.object_id, data.last.object_id + assert_same data.first, data.last end def test_binary_references @@ -60,7 +60,7 @@ module Psych - *name eoyml assert_equal data.first, data.last - assert_equal data.first.object_id, data.last.object_id + assert_same data.first, data.last end def test_regexp_references @@ -70,7 +70,7 @@ module Psych - *name eoyml assert_equal data.first, data.last - assert_equal data.first.object_id, data.last.object_id + assert_same data.first, data.last end end end diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index 3604e7c985..c1e0abb89d 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -16,13 +16,13 @@ module Psych (Handler.instance_methods(true) - Object.instance_methods).each do |m| - class_eval %{ + class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{m} *args super @marks << @parser.mark if @parser @calls << [:#{m}, args] end - } + RUBY end end @@ -85,6 +85,8 @@ module Psych def test_line_numbers assert_equal 0, @parser.mark.line + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "---\n- hello\n- world" line_calls = @handler.marks.map(&:line).zip(@handler.calls.map(&:first)) assert_equal [ @@ -110,6 +112,8 @@ module Psych def test_column_numbers assert_equal 0, @parser.mark.column + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "---\n- hello\n- world" col_calls = @handler.marks.map(&:column).zip(@handler.calls.map(&:first)) assert_equal [ @@ -135,6 +139,8 @@ module Psych def test_index_numbers assert_equal 0, @parser.mark.index + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "---\n- hello\n- world" idx_calls = @handler.marks.map(&:index).zip(@handler.calls.map(&:first)) assert_equal [ @@ -352,6 +358,8 @@ module Psych end def test_event_location + pend "Failing on JRuby" if RUBY_PLATFORM =~ /java/ + @parser.parse "foo:\n" \ " barbaz: [1, 2]" @@ -376,6 +384,25 @@ module Psych [:end_stream, [2, 0, 2, 0]]], events end + if Psych::Parser.method_defined?(:code_point_limit) + def test_code_point_limit + yaml = "foo: bar\n" * 500_000 + assert_raise(org.snakeyaml.engine.v2.exceptions.YamlEngineException) do + Psych.load(yaml) + end + + assert_nothing_raised do + begin + old_code_point_limit, Psych::Parser.code_point_limit = Psych::Parser::code_point_limit, 5_000_000 + + Psych.load(yaml) + ensure + Psych::Parser.code_point_limit = old_code_point_limit + end + end + end + end + def assert_called call, with = nil, parser = @parser if with call = parser.handler.calls.find { |x| diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb index 1abd69ceca..42586a8779 100644 --- a/test/psych/test_psych.rb +++ b/test/psych/test_psych.rb @@ -419,12 +419,41 @@ eoyml end def test_safe_dump_symbols + assert_equal Psych.dump(:foo), Psych.safe_dump(:foo, permitted_classes: [Symbol]) + assert_equal Psych.dump(:foo), Psych.safe_dump(:foo, permitted_symbols: [:foo]) + error = assert_raise Psych::DisallowedClass do - Psych.safe_dump(:foo, permitted_classes: [Symbol]) + Psych.safe_dump(:foo) end assert_equal "Tried to dump unspecified class: Symbol(:foo)", error.message - assert_match(/\A--- :foo\n(?:\.\.\.\n)?\z/, Psych.safe_dump(:foo, permitted_classes: [Symbol], permitted_symbols: [:foo])) + assert_match(/\A--- :foo\n(?:\.\.\.\n)?\z/, Psych.safe_dump(:foo, permitted_symbols: [:foo])) + end + + def test_safe_dump_stringify_names + yaml = <<-eoyml +--- +foo: + bar: bar + 'no': special escapes + 123: number +eoyml + + payload = Psych.safe_dump({ + foo: { + bar: "bar", + no: "special escapes", + 123 => "number" + } + }, stringify_names: true) + assert_equal yaml, payload + + assert_equal("---\nfoo: :bar\n", Psych.safe_dump({foo: :bar}, stringify_names: true, permitted_symbols: [:bar])) + + error = assert_raise Psych::DisallowedClass do + Psych.safe_dump({foo: :bar}, stringify_names: true) + end + assert_equal "Tried to dump unspecified class: Symbol(:bar)", error.message end def test_safe_dump_aliases diff --git a/test/psych/test_safe_load.rb b/test/psych/test_safe_load.rb index b52d6048b3..a9ed737528 100644 --- a/test/psych/test_safe_load.rb +++ b/test/psych/test_safe_load.rb @@ -19,18 +19,31 @@ module Psych end end - def test_no_recursion - x = [] - x << x - assert_raise(Psych::BadAlias) do - Psych.safe_load Psych.dump(x) + def test_raises_when_alias_found_if_alias_parsing_not_enabled + yaml_with_aliases = <<~YAML + --- + a: &ABC + k1: v1 + k2: v2 + b: *ABC + YAML + + assert_raise(Psych::AliasesNotEnabled) do + Psych.safe_load(yaml_with_aliases) end end - def test_explicit_recursion - x = [] - x << x - assert_equal(x, Psych.safe_load(Psych.dump(x), permitted_classes: [], permitted_symbols: [], aliases: true)) + def test_aliases_are_parsed_when_alias_parsing_is_enabled + yaml_with_aliases = <<~YAML + --- + a: &ABC + k1: v1 + k2: v2 + b: *ABC + YAML + + result = Psych.safe_load(yaml_with_aliases, aliases: true) + assert_same result.fetch("a"), result.fetch("b") end def test_permitted_symbol diff --git a/test/psych/test_scalar_scanner.rb b/test/psych/test_scalar_scanner.rb index 145db58fd9..02b923afe2 100644 --- a/test/psych/test_scalar_scanner.rb +++ b/test/psych/test_scalar_scanner.rb @@ -150,7 +150,7 @@ module Psych end def test_scan_strict_int_commas_and_underscores - # this test is to ensure adherance to YML spec using the 'strict_integer' option + # this test is to ensure adherence to YML spec using the 'strict_integer' option scanner = Psych::ScalarScanner.new ClassLoader.new, strict_integer: true assert_equal 123_456_789, scanner.tokenize('123_456_789') assert_equal '123,456,789', scanner.tokenize('123,456,789') diff --git a/test/psych/test_set.rb b/test/psych/test_set.rb index 87944d839e..b4968d3425 100644 --- a/test/psych/test_set.rb +++ b/test/psych/test_set.rb @@ -46,5 +46,12 @@ bar: baz @set['self'] = @set assert_cycle(@set) end + + def test_stringify_names + @set[:symbol] = :value + + assert_match(/^:symbol: :value/, Psych.dump(@set)) + assert_match(/^symbol: :value/, Psych.dump(@set, stringify_names: true)) + end end end diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index 0dc34b3083..84ae5cbb45 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -17,17 +17,17 @@ module Psych end end - # 'y' and 'n' are kind of ambiguous. Syck treated y and n literals in + # 'y', 'Y', 'n', 'N' are kind of ambiguous. Syck treated those literals in # YAML documents as strings. But this is not what the YAML 1.1 spec says. # YAML 1.1 says they should be treated as booleans. When we're dumping # documents, we know it's a string, so adding quotes will eliminate the # "ambiguity" in the emitted document - def test_y_is_quoted - assert_match(/"y"/, Psych.dump("y")) - end - def test_n_is_quoted - assert_match(/"n"/, Psych.dump("n")) + def test_all_yaml_1_1_booleans_are_quoted + yaml_1_1_booleans = %w[y Y yes Yes YES n N no No NO true True TRUE false False FALSE on On ON off Off OFF] # from https://yaml.org/type/bool.html + yaml_1_1_booleans.each do |boolean| + assert_match(/"#{boolean}"|'#{boolean}'/, Psych.dump(boolean)) + end end def test_string_with_newline diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb index e12b9769fe..cedec46cc7 100644 --- a/test/psych/test_yaml.rb +++ b/test/psych/test_yaml.rb @@ -34,7 +34,7 @@ class Psych_Unit_Tests < Psych::TestCase # [ruby-core:34969] def test_regexp_with_n - assert_cycle(Regexp.new('',0,'n')) + assert_cycle(Regexp.new('',Regexp::NOENCODING)) end # # Tests modified from 00basic.t in Psych.pm @@ -223,8 +223,8 @@ EOY &C currency: GBP &D departure: LAX &A arrival: EDI - - { *F: MADF, *C: AUD, *D: SYD, *A: MEL } - - { *F: DFSF, *C: USD, *D: JFK, *A: MCO } + - { *F : MADF, *C : AUD, *D : SYD, *A : MEL } + - { *F : DFSF, *C : USD, *D : JFK, *A : MCO } EOY ) @@ -233,20 +233,20 @@ EOY --- ALIASES: [&f fareref, &c currency, &d departure, &a arrival] FARES: -- *f: DOGMA - *c: GBP - *d: LAX - *a: EDI - -- *f: MADF - *c: AUD - *d: SYD - *a: MEL - -- *f: DFSF - *c: USD - *d: JFK - *a: MCO +- *f : DOGMA + *c : GBP + *d : LAX + *a : EDI + +- *f : MADF + *c : AUD + *d : SYD + *a : MEL + +- *f : DFSF + *c : USD + *d : JFK + *a : MCO EOY ) diff --git a/test/psych/visitors/test_emitter.rb b/test/psych/visitors/test_emitter.rb index 70adbb9ca0..8bcf5491ca 100644 --- a/test/psych/visitors/test_emitter.rb +++ b/test/psych/visitors/test_emitter.rb @@ -61,9 +61,9 @@ module Psych @visitor.accept s - assert_match(/key: value/, @io.string) + assert_include(@io.string, "key: value") assert_equal @io.string, s.yaml - assert(/\.\.\./ !~ s.yaml) + assert_not_include(s.yaml, "...") end def test_scalar @@ -76,7 +76,7 @@ module Psych @visitor.accept s - assert_match(/hello/, @io.string) + assert_include(@io.string, "hello") assert_equal @io.string, s.yaml end @@ -90,8 +90,8 @@ module Psych @visitor.accept s - assert_match(/str/, @io.string) - assert_match(/hello/, @io.string) + assert_include(@io.string, "str") + assert_include(@io.string, "hello") assert_equal @io.string, s.yaml end @@ -107,7 +107,7 @@ module Psych @visitor.accept s - assert_match(/- hello/, @io.string) + assert_include(@io.string, "- hello") assert_equal @io.string, s.yaml end @@ -122,7 +122,7 @@ module Psych @visitor.accept s - assert_match(/key: value/, @io.string) + assert_include(@io.string, "key: value") assert_equal @io.string, s.yaml end @@ -137,7 +137,7 @@ module Psych @visitor.accept s - assert_match(/&A key: \*A/, @io.string) + assert_include(@io.string, "&A key: \*A") assert_equal @io.string, s.yaml end end diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb index 3d4608b903..89c3676651 100644 --- a/test/psych/visitors/test_to_ruby.rb +++ b/test/psych/visitors/test_to_ruby.rb @@ -319,7 +319,7 @@ description: list = seq.to_ruby assert_equal %w{ foo foo }, list - assert_equal list[0].object_id, list[1].object_id + assert_same list[0], list[1] end def test_mapping_with_str_tag diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb index 4c48670f2f..01e685134a 100644 --- a/test/psych/visitors/test_yaml_tree.rb +++ b/test/psych/visitors/test_yaml_tree.rb @@ -34,7 +34,7 @@ module Psych v << "hello world" v.finish - assert_match "hello world", io.string + assert_include io.string, "hello world" end def test_binary_formatting @@ -167,9 +167,9 @@ module Psych end def test_string - assert_match(/'017'/, Psych.dump({'a' => '017'})) - assert_match(/'019'/, Psych.dump({'a' => '019'})) - assert_match(/'01818'/, Psych.dump({'a' => '01818'})) + assert_include(Psych.dump({'a' => '017'}), "'017'") + assert_include(Psych.dump({'a' => '019'}), "'019'") + assert_include(Psych.dump({'a' => '01818'}), "'01818'") end # http://yaml.org/type/null.html |