Sha256: 6bdad6e63edf48193515daa8f9a8404c33904a31999692d0f2ba75e2edafbce6

Contents?: true

Size: 883 Bytes

Versions: 76

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHS::Collection do
  let(:items) { [{ name: 'Steve' }] }
  let(:extra) { 'extra' }
  let(:collection) { Record.where }

  context 'to_ary' do
    before do
      class Record < LHS::Record
        endpoint 'http://datastore/records`'
      end
      stub_request(:get, %r{http://datastore/records})
        .to_return(body: response_data.to_json)
    end

    let(:response_data) do
      {
        items: items,
        extra: extra,
        total: 1
      }
    end

    let(:subject) { collection.to_ary }

    it 'returns an array' do
      expect(subject).to be_present
      expect(subject).to be_kind_of Array
      expect(subject[0]).to be_kind_of Record
      expect(subject[0].name).to eq 'Steve'
    end

    it 'responds to to_ary' do
      expect(subject.respond_to?(:to_ary)).to eq true
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
lhs-22.1.1.pre spec/collection/to_ary_spec.rb
lhs-22.1.0 spec/collection/to_ary_spec.rb
lhs-22.0.0 spec/collection/to_ary_spec.rb
lhs-21.3.1 spec/collection/to_ary_spec.rb
lhs-21.3.0 spec/collection/to_ary_spec.rb
lhs-21.3.0.pre.autoauth.1 spec/collection/to_ary_spec.rb
lhs-21.2.4 spec/collection/to_ary_spec.rb
lhs-21.2.3 spec/collection/to_ary_spec.rb
lhs-21.2.3.pre.preload.pre.providers.pre.too.1 spec/collection/to_ary_spec.rb
lhs-21.2.2 spec/collection/to_ary_spec.rb
lhs-21.2.1 spec/collection/to_ary_spec.rb
lhs-21.2.0 spec/collection/to_ary_spec.rb
lhs-21.1.4 spec/collection/to_ary_spec.rb
lhs-21.1.3 spec/collection/to_ary_spec.rb
lhs-21.1.2 spec/collection/to_ary_spec.rb
lhs-21.1.2.pre.keyfix.2 spec/collection/to_ary_spec.rb
lhs-21.1.2.pre.keyfix.1 spec/collection/to_ary_spec.rb
lhs-21.1.2.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/collection/to_ary_spec.rb
lhs-21.1.1.pre.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 spec/collection/to_ary_spec.rb
lhs-21.1.0 spec/collection/to_ary_spec.rb