Sha256: 78f6e77c0e66566a4de77b42a668b06f4345a21c13036d7cee281b666b23f84c

Contents?: true

Size: 1.42 KB

Versions: 27

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal = true

RSpec.describe :dump_as_json do
  link :dump_as_json, from: :ree_object
  link :load_json_dump, from: :ree_object

  let(:klass) {
    class TestObjCLass
      attr_reader :integer, :string, :array, :hash, :object, :klass, :module

      def initialize
        @integer = 1
        @string = 'string'
        @array = [1, 'string', 3, { 'name' => 'John'}]

        @hash = {
          id: 1,
          'test' => 2,
          nested: {
            some_value: 1,
            another_value: 2
          },
          name: 'name'
        }

        @object = Object.new
        @klass = Object
        @module = Module

        @object.instance_exec do
          @name = 'John'
          @last_name = 'Doe'
        end
      end
    end

    TestObjCLass
  }

  context "object" do
    it {
      orig_obj = klass.new
      result = dump_as_json([orig_obj])
      obj = load_json_dump(result).first

      expect(obj.integer).to eq(orig_obj.integer)
      expect(obj.string).to eq(orig_obj.string)
      expect(obj.array).to eq(orig_obj.array)
      expect(obj.hash).to eq(orig_obj.hash)
      expect(obj.klass).to eq(orig_obj.klass)
      expect(obj.module).to eq(orig_obj.module)
      expect(obj.object.instance_variable_get(:@name)).to eq(orig_obj.object.instance_variable_get(:@name))
      expect(obj.object.instance_variable_get(:@last_name)).to eq(orig_obj.object.instance_variable_get(:@last_name))
    }
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ree_lib-1.0.39 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.38 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.37 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.36 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.35 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.34 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.33 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.32 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.31 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.30 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.24 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.23 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.22 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.21 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.20 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb
ree_lib-1.0.19 lib/ree_lib/packages/ree_object/spec/ree_object/functions/dump_as_json_spec.rb