Sha256: 2570840670f5e1d75b01150011e8a5b546bc73426630216f225d4c87618990de

Contents?: true

Size: 831 Bytes

Versions: 12

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe DHS::Record do
  context 'definitions' do
    let(:datastore) { 'http://depay.fi/v2' }

    before do
      DHC.config.placeholder('datastore', datastore)
      class LocalEntry < DHS::Record
        endpoint '{+datastore}/local-entries'
        endpoint '{+datastore}/local-entries/{id}'
      end
    end

    it 'allows mappings in all functions/defitions' do
      class LocalEntry < DHS::Record
        def name
          addresses.first.business.identities.first.name
        end
      end
      stub_request(:get, "#{datastore}/local-entries/1")
        .to_return(status: 200, body: { addresses: [{ business: { identities: [{ name: 'Löwenzorn' }] } }] }.to_json)
      entry = LocalEntry.find(1)
      expect(entry.name).to eq 'Löwenzorn'
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 spec/record/definitions_spec.rb
dhs-1.5.0 spec/record/definitions_spec.rb
dhs-1.4.2 spec/record/definitions_spec.rb
dhs-1.4.1 spec/record/definitions_spec.rb
dhs-1.4.0 spec/record/definitions_spec.rb
dhs-1.3.0 spec/record/definitions_spec.rb
dhs-1.2.0 spec/record/definitions_spec.rb
dhs-1.1.0 spec/record/definitions_spec.rb
dhs-1.0.3 spec/record/definitions_spec.rb
dhs-1.0.2 spec/record/definitions_spec.rb
dhs-1.0.1 spec/record/definitions_spec.rb
dhs-1.0.0 spec/record/definitions_spec.rb