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-4.2.2 spec/rock_rms/response/group_location_spec.rb
rock_rms-4.2.1 spec/rock_rms/response/group_location_spec.rb
rock_rms-4.2.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-4.1.1 spec/rock_rms/response/group_location_spec.rb
rock_rms-4.1.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-4.0.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.9.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.8.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.7.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.6.3 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.6.2 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.6.1 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.6.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.5.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.4.1 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.4.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.2.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.1.0 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.0.2 spec/rock_rms/response/group_location_spec.rb
rock_rms-3.0.1 spec/rock_rms/response/group_location_spec.rb