Sha256: 49b30a34665bd9f648b82dc3d8427aea9ebb7627e0decc597ffc901e3fd43c4c

Contents?: true

Size: 1.1 KB

Versions: 30

Compression:

Stored size: 1.1 KB

Contents

RSpec.describe :register_type do
  link :register_type, from: :ree_swagger
  link :build_serializer_schema, from: :ree_swagger
  link :build_mapper_factory, from: :ree_mapper
  link :build_mapper_strategy, from: :ree_mapper

  class ReeSwagger::MyType < ReeMapper::AbstractType
    def serialize(obj, role: nil)
      obj.inspect
    end
  end

  let(:mapper_factory) {
    strategies = [
      build_mapper_strategy(method: :serialize, output: :symbol_key_hash),
    ]

    build_mapper_factory(strategies: strategies).register(
      :my_type,
      ReeMapper::Mapper.build(
        strategies,
        ReeSwagger::MyType.new
      )
    )
  }

  let(:mapper) {
    mapper_factory.call.use(:serialize) do
      my_type :name
    end
  }

  before do
    register_type(
      :serializers,
      ReeSwagger::MyType,
      ->(my_type, build_serializer_schema) {
        {
          type: 'string'
        }
      }
    )
  end

  it {
    expect(build_serializer_schema(mapper)).to eq(
      {
        type: 'object',
        properties: {
          name: {
            type: 'string'
          }
        }
      }
    )
  }
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
ree_lib-1.0.30 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.29 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.28 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.27 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.26 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.24 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.23 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.22 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.21 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.20 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.19 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.18 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.17 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.16 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.15 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.14 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.13 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.12 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.11 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb
ree_lib-1.0.10 lib/ree_lib/packages/ree_swagger/spec/functions/register_type_spec.rb