Sha256: c3a07d3120f87f4f85027cd1bf216f9a918ad015baa90c4cee4505f6380f8ef0

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

describe Delayed::JobGroups::YamlLoader do
  class Foo; end

  describe "#load" do
    context "with a correct yaml object representation" do
      let(:yaml) { '--- !ruby/object:Foo {}' }

      it "deserializes from YAML properly" do
        expect(Delayed::JobGroups::YamlLoader.load(yaml)).to be_a(Foo)
      end
    end

    context "with incorrect yaml object representations" do
      let(:not_yaml1) { 'foo' }
      let(:not_yaml2) { 1 }

      it "deserializes from YAML properly" do
        expect(Delayed::JobGroups::YamlLoader.load(not_yaml1)).to eq('foo')
        expect(Delayed::JobGroups::YamlLoader.load(not_yaml2)).to eq(1)
      end
    end
  end

  describe "#dump" do
    context "with an object" do
      let(:object) { Foo.new }

      it "serializes into YAML properly" do
        expect(Delayed::JobGroups::YamlLoader.dump(object)).to eq("--- !ruby/object:Foo {}\n")
      end
    end

    context "with a nil object" do
      let(:object) { nil }

      it "serializes into YAML properly" do
        expect(Delayed::JobGroups::YamlLoader.dump(object)).to eq(nil)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
delayed_job_groups_plugin-0.6.2 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.6.0 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.5.0 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.4.3 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.4.2 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.4.1 spec/delayed/job_groups/yaml_loader_spec.rb