Sha256: cc73efbb28d8606def06c540c342c6370e164e336102fd84e9021090d6b29a4c

Contents?: true

Size: 852 Bytes

Versions: 19

Compression:

Stored size: 852 Bytes

Contents

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

19 entries across 19 versions & 1 rubygems

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