Sha256: 3e32894570c5062f76e459e1675178edd1ed55f6c85e0cdc58e655980b475299

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'helper'

describe 'YAML' do
  it 'autoloads classes' do
    expect do
      yaml = "--- !ruby/class Autoloaded::Clazz\n"
      expect(YAML.load(yaml)).to eq(Autoloaded::Clazz)
    end.not_to raise_error
  end

  it 'autoloads the class of a struct' do
    expect do
      yaml = "--- !ruby/class Autoloaded::Struct\n"
      expect(YAML.load(yaml)).to eq(Autoloaded::Struct)
    end.not_to raise_error
  end

  it 'autoloads the class for the instance of a struct' do
    expect do
      yaml = '--- !ruby/struct:Autoloaded::InstanceStruct {}'
      expect(YAML.load(yaml).class).to eq(Autoloaded::InstanceStruct)
    end.not_to raise_error
  end

  it 'autoloads the class for the instance' do
    expect do
      yaml = "--- !ruby/object:Autoloaded::InstanceClazz {}\n"
      expect(YAML.load(yaml).class).to eq(Autoloaded::InstanceClazz)
    end.not_to raise_error
  end

  it 'does not throw an uninitialized constant Syck::Syck when using YAML.load with poorly formed yaml' do
    expect { YAML.load(YAML.dump('foo: *bar')) }.not_to raise_error
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
delayed_job-4.0.3 spec/yaml_ext_spec.rb