Sha256: 113ef758641051c29948d0bbeadea7899c0d7fdc34214c3e77925481955da8d0

Contents?: true

Size: 584 Bytes

Versions: 9

Compression:

Stored size: 584 Bytes

Contents

require 'helper'

class StructWithIvar < Struct.new(:foo)
  attr_reader :bar
  def initialize *args
    super
    @bar = 'hello'
  end
end

module Syck
  class TestStruct < Test::Unit::TestCase
    def test_roundtrip
      thing = StructWithIvar.new('bar')
      struct = Syck.load(Syck.dump(thing))

      assert_equal 'hello', struct.bar
      assert_equal 'bar', struct.foo
    end

    def test_load
      obj = Syck.load(<<-eoyml)
--- !ruby/struct:StructWithIvar
foo: bar
@bar: hello
eoyml

      assert_equal 'hello', obj.bar
      assert_equal 'bar', obj.foo
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
syck-1.5.1.1 test/test_struct.rb
syck-1.5.1 test/test_struct.rb
syck-1.5.0 test/test_struct.rb
syck-1.4.1 test/test_struct.rb
syck-1.4.0 test/test_struct.rb
syck-1.3.0 test/test_struct.rb
syck-1.2.0 test/test_struct.rb
syck-1.1.0 test/test_struct.rb
syck-1.0.5 test/test_struct.rb