Sha256: f5e41cacdc522cc7f8d425d1e594f81e776fd1b54e69f4397d61d31c9dec7c28

Contents?: true

Size: 1.02 KB

Versions: 121

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

RSpec.describe RockRMS::Response::GroupLocation, type: :model do
  let(:parsed) { JSON.parse(FixturesHelper.read('group_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[:group_id]).to eq(p['GroupId'])
        expect(r[:location_id]).to eq(p['LocationId'])
        expect(r[:guid]).to eq(p['Guid'])
      end
    end

    context 'when locations are included' do
      it 'formats with Location' do
        location = double
        parsed.first['Location'] = location
        expect(RockRMS::Response::Location).to receive(:format)
          .with(location)
          .and_return(some_key: :value)
        result
        expect(result.first[:location]).to eq(some_key: :value)
      end
    end
  end
end

Version data entries

121 entries across 121 versions & 1 rubygems

Version Path
rock_rms-9.10.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.9.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.8.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.7.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.6.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.5.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.4.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.3.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.2.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.1.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-9.0.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.23.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.22.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.21.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.20.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.19.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.18.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.17.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.16.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-8.15.2 spec/rock_rms/response/group_location_spec.rb