Sha256: 622b4aea71f22a4fcc9c9336e9519430e6e3cbf924357e5d8182ca59b8897e4f
Contents?: true
Size: 1.24 KB
Versions: 11
Compression:
Stored size: 1.24 KB
Contents
require 'helper' describe 'Psych::Visitors::ToRuby', :if => defined?(Psych::Visitors::ToRuby) do context BigDecimal do it 'deserializes correctly' do deserialized = YAML.load_dj("--- !ruby/object:BigDecimal 18:0.1337E2\n...\n") expect(deserialized).to be_an_instance_of(BigDecimal) expect(deserialized).to eq(BigDecimal('13.37')) end end context 'load_tag handling' do # This only broadly works in ruby 2.0 but will cleanly work through load_dj # here because this class is so simple it only touches our extention YAML.load_tags['!ruby/object:RenamedClass'] = SimpleJob # This is how ruby 2.1 and newer works throughout the yaml handling YAML.load_tags['!ruby/object:RenamedString'] = 'SimpleJob' it 'deserializes class tag' do deserialized = YAML.load_dj("--- !ruby/object:RenamedClass\ncheck: 12\n") expect(deserialized).to be_an_instance_of(SimpleJob) expect(deserialized.instance_variable_get(:@check)).to eq(12) end it 'deserializes string tag' do deserialized = YAML.load_dj("--- !ruby/object:RenamedString\ncheck: 12\n") expect(deserialized).to be_an_instance_of(SimpleJob) expect(deserialized.instance_variable_get(:@check)).to eq(12) end end end
Version data entries
11 entries across 11 versions & 1 rubygems