Sha256: 0526da997d1949d64adb2629ee810012b7854d7be03fe8de065483ec6c0d9064

Contents?: true

Size: 839 Bytes

Versions: 8

Compression:

Stored size: 839 Bytes

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(10)
    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'])
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rock_rms-8.8.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.7.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.6.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.5.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.4.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.3.0 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.2.1 spec/rock_rms/response/attribute_value_spec.rb
rock_rms-8.2.0 spec/rock_rms/response/attribute_value_spec.rb