Sha256: f23dbeda10f3dff5a65267e4dc21dd5830da4a75d89ca82979429684576e1072

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

RSpec.describe RockRMS::Responses::Location, type: :model do
  let(:parsed) { JSON.parse(FixturesHelper.read('locations.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 'translates keys' do
      result.zip(parsed) do |r, p|
        expect(r[:id]).to eq(p['Id'])
        expect(r[:name]).to eq(p['Name'])
        expect(r[:is_active]).to eq(p['IsActive'])
        expect(r[:street1]).to eq(p['Street1'])
        expect(r[:street2]).to eq(p['Street2'])
        expect(r[:city]).to eq(p['City'])
        expect(r[:county]).to eq(p['County'])
        expect(r[:state]).to eq(p['State'])
        expect(r[:country]).to eq(p['Country'])
        expect(r[:postal_code]).to eq(p['PostalCode'])
        expect(r[:latitude]).to eq(p['Latitude'])
        expect(r[:longitude]).to eq(p['Longitude'])
        expect(r[:guid]).to eq(p['Guid'])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rock_rms-2.0.0 spec/rock_rms/responses/location_spec.rb
rock_rms-1.3.0 spec/rock_rms/responses/location_spec.rb
rock_rms-1.2.0 spec/rock_rms/responses/location_spec.rb
rock_rms-1.1.0 spec/rock_rms/responses/location_spec.rb