Sha256: daa8375a2cf06b56a804c19772114f18da3a4cd2393e162e3ec6d9c6e7da45ee

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 KB

Contents

require 'helper'

describe 'YAML' do
  it 'autoloads classes' do
    expect do
      yaml = "--- !ruby/class Autoloaded::Clazz\n"
      expect(load_with_delayed_visitor(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(load_with_delayed_visitor(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(load_with_delayed_visitor(yaml).class).to eq(Autoloaded::InstanceStruct)
    end.not_to raise_error
  end

  it 'autoloads the class of an anonymous struct' do
    expect do
      yaml = "--- !ruby/struct\nn: 1\n"
      object = YAML.load(yaml)
      expect(object).to be_kind_of(Struct)
      expect(object.n).to eq(1)
    end.not_to raise_error
  end

  it 'autoloads the class for the instance' do
    expect do
      yaml = "--- !ruby/object:Autoloaded::InstanceClazz {}\n"
      expect(load_with_delayed_visitor(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

  def load_with_delayed_visitor(yaml)
    YAML.load_dj(yaml)
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
delayed_job-4.1.9 spec/yaml_ext_spec.rb
delayed_job-4.1.8 spec/yaml_ext_spec.rb
delayed_job-4.1.8.beta1 spec/yaml_ext_spec.rb
delayed_job-4.1.7 spec/yaml_ext_spec.rb
delayed_job-4.1.7.beta1 spec/yaml_ext_spec.rb
delayed_job-4.1.6 spec/yaml_ext_spec.rb
delayed_job-4.1.6.beta1 spec/yaml_ext_spec.rb
delayed_job-4.1.5 spec/yaml_ext_spec.rb
delayed_job-4.1.4 spec/yaml_ext_spec.rb
delayed_job-4.1.3 spec/yaml_ext_spec.rb
delayed_job-4.1.2 spec/yaml_ext_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/delayed_job-4.1.1/spec/yaml_ext_spec.rb
delayed_job-4.1.1 spec/yaml_ext_spec.rb
delayed_job-4.1.0 spec/yaml_ext_spec.rb
delayed_job_tgmerritt-4.0.7 spec/yaml_ext_spec.rb
delayed_job-4.0.6 spec/yaml_ext_spec.rb
delayed_job-4.0.4 spec/yaml_ext_spec.rb