Sha256: 81a3d677a3b37dba4beb51f6af7ba94cfeb8bf82751b9ab65b2f9df4ed01eea3

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

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

      it "deserializes from YAML properly" do
        expect(Delayed::JobGroups::YamlLoader.load(yaml)).to be_a(TestJobs::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) { TestJobs::Foo.new }

      it "serializes into YAML properly" do
        expect(Delayed::JobGroups::YamlLoader.dump(object)).to eq("--- !ruby/object:TestJobs::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

7 entries across 7 versions & 1 rubygems

Version Path
delayed_job_groups_plugin-0.12.0 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.11.0 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.10.1 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.10.0 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.9.0 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.8.0 spec/delayed/job_groups/yaml_loader_spec.rb
delayed_job_groups_plugin-0.7.0 spec/delayed/job_groups/yaml_loader_spec.rb