Sha256: 050076f4172e892c8cf7807b2db8fa269d6b65fcd43b4cf2cb5571c17ef98b46

Contents?: true

Size: 1002 Bytes

Versions: 47

Compression:

Stored size: 1002 Bytes

Contents

require 'rails_helper'

describe LHS::Record do
  before(:each) 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

47 entries across 47 versions & 1 rubygems

Version Path
lhs-14.6.1 spec/record/items_created_key_configuration_spec.rb
lhs-14.6.0 spec/record/items_created_key_configuration_spec.rb
lhs-14.5.0 spec/record/items_created_key_configuration_spec.rb
lhs-14.4.0 spec/record/items_created_key_configuration_spec.rb
lhs-14.3.4 spec/record/items_created_key_configuration_spec.rb
lhs-14.3.3 spec/record/items_created_key_configuration_spec.rb
lhs-14.3.2 spec/record/items_created_key_configuration_spec.rb
lhs-14.3.1 spec/record/items_created_key_configuration_spec.rb
lhs-14.3.0 spec/record/items_created_key_configuration_spec.rb
lhs-14.2.0 spec/record/items_created_key_configuration_spec.rb
lhs-14.1.1 spec/record/items_created_key_configuration_spec.rb
lhs-14.1.0 spec/record/items_created_key_configuration_spec.rb
lhs-14.0.3 spec/record/items_created_key_configuration_spec.rb
lhs-14.0.2 spec/record/items_created_key_configuration_spec.rb
lhs-14.0.1 spec/record/items_created_key_configuration_spec.rb
lhs-14.0.0 spec/record/items_created_key_configuration_spec.rb
lhs-13.2.3 spec/record/items_created_key_configuration_spec.rb
lhs-13.2.2 spec/record/items_created_key_configuration_spec.rb
lhs-13.2.1 spec/record/items_created_key_configuration_spec.rb
lhs-13.2.0 spec/record/items_created_key_configuration_spec.rb