Sha256: c86ace20838306bd5a7c013d449c857b3ac680137d3c41d925105d40fd9d2825

Contents?: true

Size: 1.14 KB

Versions: 17

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

RSpec.describe RockRMS::Response::AttributeValue, type: :model do
  let(:parsed) { JSON.parse(FixturesHelper.read('attribute_values.json')) }

  describe '.format' do
    subject(:result) { described_class.format(parsed) }

    context 'when response is array' do
      it 'returns an array' do
        expect(described_class.format([])).to be_a(Array)
      end
    end

    it 'has the correct number keys' do
      keys = result.first.keys
      expect(keys.count).to eq(11)
    end

    it 'translates keys' do
      result.zip(parsed) do |r, p|
        expect(r[:id]).to eq(p['Id'])
        expect(r[:guid]).to eq(p['Guid'])
        expect(r[:value]).to eq(p['Value'])
        expect(r[:value_as_number]).to eq(p['ValueAsNumeric'])
        expect(r[:entity_id]).to eq(p['EntityId'])
        expect(r[:attribute]).to eq({
          attribute_values: nil,
          attributes: nil,
          created_date_time: nil,
          description: nil,
          entity_type_id: 7,
          guid: "abcd",
          id: 22,
          key: "JobPulse",
          modified_date_time: nil,
          name: "Job Pulse"
        })
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rock_rms-8.23.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.22.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.21.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.20.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.19.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.18.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.17.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.16.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.15.2 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.15.1 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.15.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.14.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.13.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.12.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.11.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.10.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.9.0 spec/rock_rms/response/attribute_value_spec.rb