Sha256: 947faf13f941be3c107e3d8410c7fe30721bf2715d7a3b24766beb053269c8dc

Contents?: true

Size: 995 Bytes

Versions: 19

Compression:

Stored size: 995 Bytes

Contents

require 'rails_helper'

describe LHS::Record do
  before do
    class Business < LHS::Record
      configuration item_created_key: [:response, :business], limit_key: [:response, :max], pagination_key: [:response, :offset], total_key: [:response, :count], pagination_strategy: :offset
      endpoint 'http://uberall/businesses'
    end
  end

  let(:stub_create_business_request) do
    stub_request(:post, "http://uberall/businesses")
      .to_return(body: {
        status: "SUCCESS",
        response: {
          business: {
            identifier: 'ABC123',
            name: 'localsearch',
            id: 239650
          }
        }
      }.to_json)
  end

  it 'uses paths from configuration to access nested values' do
    stub_create_business_request
    business = Business.create!(
      identifier: 'ABC123',
      name: 'localsearch'
    )
    expect(business.identifier).to eq 'ABC123'
    expect(business.name).to eq 'localsearch'
    expect(business.id).to eq 239650
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
lhs-16.1.5 spec/record/items_created_key_configuration_spec.rb
lhs-16.1.4 spec/record/items_created_key_configuration_spec.rb
lhs-16.1.3 spec/record/items_created_key_configuration_spec.rb
lhs-16.1.2 spec/record/items_created_key_configuration_spec.rb
lhs-16.1.1 spec/record/items_created_key_configuration_spec.rb
lhs-16.1.0 spec/record/items_created_key_configuration_spec.rb
lhs-16.0.1 spec/record/items_created_key_configuration_spec.rb
lhs-16.0.0 spec/record/items_created_key_configuration_spec.rb
lhs-15.7.0 spec/record/items_created_key_configuration_spec.rb
lhs-15.6.1 spec/record/items_created_key_configuration_spec.rb
lhs-15.6.0 spec/record/items_created_key_configuration_spec.rb
lhs-15.5.1 spec/record/items_created_key_configuration_spec.rb
lhs-15.5.0 spec/record/items_created_key_configuration_spec.rb
lhs-15.4.1 spec/record/items_created_key_configuration_spec.rb
lhs-15.4.0 spec/record/items_created_key_configuration_spec.rb
lhs-15.4.0.pre.hasone.1 spec/record/items_created_key_configuration_spec.rb
lhs-15.3.3 spec/record/items_created_key_configuration_spec.rb
lhs-15.3.3.pre.fixoptions.1 spec/record/items_created_key_configuration_spec.rb
lhs-15.3.2 spec/record/items_created_key_configuration_spec.rb