Sha256: 8aa6190fe428c5c97c2b9ab30c6c10fe5ba0ff9c4058ac86811f215bc7e9d837

Contents?: true

Size: 786 Bytes

Versions: 27

Compression:

Stored size: 786 Bytes

Contents

require_relative 'helper'

module Psych
  class Tagged
    yaml_tag '!foo'

    attr_accessor :baz

    def initialize
      @baz = 'bar'
    end
  end

  class Foo
    attr_accessor :parent

    def initialize parent
      @parent = parent
    end
  end

  class TestObject < TestCase
    def test_dump_with_tag
      tag = Tagged.new
      assert_match('foo', Psych.dump(tag))
    end

    def test_tag_round_trip
      tag   = Tagged.new
      tag2  = Psych.load(Psych.dump(tag))
      assert_equal tag.baz, tag2.baz
      assert_instance_of(Tagged, tag2)
    end

    def test_cyclic_references
      foo = Foo.new(nil)
      foo.parent = foo
      loaded = Psych.load Psych.dump foo

      assert_instance_of(Foo, loaded)
      assert_equal loaded, loaded.parent
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
psych-2.0.17-java test/psych/test_object.rb
psych-2.0.17 test/psych/test_object.rb
psych-2.0.16-java test/psych/test_object.rb
psych-2.0.16 test/psych/test_object.rb
psych-2.0.15-java test/psych/test_object.rb
psych-2.0.15 test/psych/test_object.rb
psych-2.0.14-java test/psych/test_object.rb
psych-2.0.14 test/psych/test_object.rb
psych-shopifork-2.0.13 test/psych/test_object.rb
psych-2.0.14.pre1-java test/psych/test_object.rb
psych-2.0.13 test/psych/test_object.rb
psych-2.0.12 test/psych/test_object.rb
psych-2.0.11 test/psych/test_object.rb
psych-2.0.10 test/psych/test_object.rb
psych-2.0.9 test/psych/test_object.rb
psych-2.0.8 test/psych/test_object.rb
psych-2.0.7 test/psych/test_object.rb
psych-2.0.6 test/psych/test_object.rb
psych-shopifork-2.0.5 test/psych/test_object.rb
psych-2.0.5 test/psych/test_object.rb