Sha256: 903ecd7b9e7d867279bcb43fba1605ba0f604b0c4e13d9de3f4ac29587804c48
Contents?: true
Size: 1.64 KB
Versions: 12
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true require 'rails_helper' require 'dhs/rspec' describe DHS do before do class Record < DHS::Record endpoint 'https://records' end Record.stub_all( 'https://records', 200.times.map { |index| { name: "Item #{index}" } }, headers: { 'Authorization' => 'Bearer 123' } ) end it 'stubs all requests' do records = Record.options(headers: { 'Authorization' => 'Bearer 123' }).all.fetch expect(records.count).to eq 200 expect(records.length).to eq 200 expect(records.first.name).to eq 'Item 0' end context 'without conditions' do before do class Record < DHS::Record endpoint 'https://records' end Record.stub_all( 'https://records', 200.times.map { |index| { name: "Item #{index}" } } ) end it 'stubs all requests without a webmock "with"' do records = Record.all.fetch expect(records.count).to eq 200 expect(records.length).to eq 200 expect(records.first.name).to eq 'Item 0' end end context 'with configured record' do before do class Record < DHS::Record configuration limit_key: :per_page, pagination_strategy: :page, pagination_key: :page endpoint 'https://records' end Record.stub_all( 'https://records', 200.times.map { |index| { name: "Item #{index}" } } ) end it 'stubs all requests with record configurations for pagination' do records = Record.all.fetch expect(records.count).to eq 200 expect(records.length).to eq 200 expect(records.first.name).to eq 'Item 0' end end end
Version data entries
12 entries across 12 versions & 1 rubygems