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-26.2.0 spec/record/fetch_spec.rb
lhs-26.1.0 spec/record/fetch_spec.rb
lhs-26.0.1 spec/record/fetch_spec.rb
lhs-26.0.0 spec/record/fetch_spec.rb
lhs-25.2.0 spec/record/fetch_spec.rb
lhs-25.1.0 spec/record/fetch_spec.rb
lhs-25.0.4 spec/record/fetch_spec.rb
lhs-25.0.3 spec/record/fetch_spec.rb
lhs-25.0.2 spec/record/fetch_spec.rb
lhs-25.0.1 spec/record/fetch_spec.rb
lhs-25.0.0 spec/record/fetch_spec.rb
lhs-24.1.2 spec/record/fetch_spec.rb
lhs-24.1.1 spec/record/fetch_spec.rb
lhs-24.1.0 spec/record/fetch_spec.rb
lhs-24.1.0.pre.2 spec/record/fetch_spec.rb
lhs-24.1.0.pre.1 spec/record/fetch_spec.rb
lhs-24.0.0 spec/record/fetch_spec.rb
lhs-23.0.2 spec/record/fetch_spec.rb
lhs-23.0.1 spec/record/fetch_spec.rb
lhs-23.0.0 spec/record/fetch_spec.rb