Sha256: e0e1182f749b692af07fe6df116ca4eb6e23a6560e251ecb80845d3a69f11520

Contents?: true

Size: 1.04 KB

Versions: 76

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHS::Record do
  before do
    class Record < LHS::Record
      endpoint 'http://datastore/records/'
    end
  end

  context 'fetch' do

    context 'to resolve the chain' do
      let!(:request_stub) do
        stub_request(:get, "http://datastore/records/?available=true&color=blue&range=%3E26")
          .to_return(body: [{
            name: 'Steve'
          }].to_json)
      end

      it 'resolves chains' do
        records = Record.where(color: 'blue').where(range: '>26', available: true).fetch
        expect(request_stub).to have_been_requested
        expect(records.first.name).to eq 'Steve'
      end
    end

    context 'to fetch the first response' do
      let!(:request_stub) do
        stub_request(:get, "http://datastore/records/")
          .to_return(body: [{ name: 'Steve' }])
      end

      it 'does fetch the first response if requested directly on the record' do
        records = Record.fetch
        expect(records.first.name).to eq 'Steve'
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
lhs-21.0.0 spec/record/fetch_spec.rb
lhs-20.1.4 spec/record/fetch_spec.rb
lhs-20.1.3.pre.paginationfix.3 spec/record/fetch_spec.rb
lhs-20.1.3.pre.paginationfix.2 spec/record/fetch_spec.rb
lhs-20.1.3.pre.paginationfix.1 spec/record/fetch_spec.rb
lhs-20.1.2 spec/record/fetch_spec.rb
lhs-20.1.1 spec/record/fetch_spec.rb
lhs-20.0.0 spec/record/fetch_spec.rb
lhs-19.10.0 spec/record/fetch_spec.rb
lhs-19.9.0 spec/record/fetch_spec.rb
lhs-19.8.2 spec/record/fetch_spec.rb
lhs-19.8.1 spec/record/fetch_spec.rb
lhs-19.8.0 spec/record/fetch_spec.rb
lhs-19.7.0 spec/record/fetch_spec.rb
lhs-19.6.0 spec/record/fetch_spec.rb
lhs-19.5.0 spec/record/fetch_spec.rb
lhs-19.5.0.pre.wherehref.1 spec/record/fetch_spec.rb
lhs-19.4.1 spec/record/fetch_spec.rb
lhs-19.4.0 spec/record/fetch_spec.rb
lhs-19.3.1 spec/record/fetch_spec.rb