Sha256: 2e7d2d406c79e9c341c1529f5cbcc5fae9b14e0257c31da264a77e0eefbe0b16

Contents?: true

Size: 1.95 KB

Versions: 2

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

#
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

require './spec/spec_helper'

describe CinnamonSerial::Dsl do
  let(:employee_list_keys) do
    %w[
      active
      id
      name
      user_id
      user_name
      other_id
      manager_name
      renewal_date
      notify_date
      true_alias_value
      false_alias_value
      null
      present
      blank
      manager
      employees
      account
      progress
    ]
  end

  let(:employee_keys) do
    employee_list_keys + %w[
      start_date
      job
      founder
      owner
    ]
  end

  it 'should include all attribute mappings' do
    specification = EmployeeListSerializer.cinnamon_serial_specification
    attribute_map = specification.attribute_map
    keys = attribute_map.keys

    expect(specification).to  be_a_kind_of(CinnamonSerial::Specification)
    expect(keys.count).to     eq(employee_list_keys.count)
    expect(keys).to           eq(employee_list_keys)
  end

  context 'with inheritance' do
    it 'should include only its immediate attribute mappings' do
      specification = EmployeeSerializer.cinnamon_serial_specification
      attribute_map = specification.attribute_map
      keys = attribute_map.keys

      expect(specification).to  be_a_kind_of(CinnamonSerial::Specification)
      expect(keys.count).to     eq(4)
      expect(keys).to           eq(%w[start_date job founder owner])
    end

    it 'should include its immediate and ancestor attribute mappings' do
      specification = EmployeeSerializer.inherited_cinnamon_serial_specification
      attribute_map = specification.attribute_map
      keys = attribute_map.keys

      expect(specification).to  be_a_kind_of(CinnamonSerial::Specification)
      expect(keys.count).to     eq(employee_keys.count)
      expect(keys).to           eq(employee_keys)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cinnamon_serial-2.1.2 spec/cinnamon_serial/dsl_spec.rb
cinnamon_serial-2.1.1 spec/cinnamon_serial/dsl_spec.rb