Sha256: 6f2136e8fb4379fc7326c5d68350bfc660e51d3b5bcaceaef7a4059465eb931f
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
# frozen_string_literal: true # # Copyright (c) 2019-present, Blue Marble Payroll, LLC # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # require './spec/spec_helper' describe ::Airspace::Reader do let(:client) { Redis.new } let(:id) { 'reader-test-set' } let(:options) { { prefix: TEST_PREFIX } } let(:reader) { ::Airspace.get(client, id, options: options) } subject { reader } context 'with no pages' do before(:each) do ::Airspace.set(client, id: id, options: options) end describe '#page' do it 'should return empty array when page_count is 0' do expect(subject.page(1)).to eq([]) end it 'should return empty array when number <= 0' do expect(subject.page(-1)).to eq([]) end end describe '#pages' do it 'should return empty array when page_count is 0' do expect(subject.pages).to eq([]) end end end context 'with pages' do let(:pages) do [ [ { 'id' => 1, 'name' => 'Matt' } ] ] end before(:each) do ::Airspace.set(client, id: id, options: options, pages: pages) end describe '#page' do it 'should return array of rows when number <= page_count' do expect(subject.page(1)).to eq(pages[0]) end it 'should return empty array when number > page_count' do expect(subject.page(2)).to eq([]) end it 'should return empty array when number <= 0' do expect(subject.page(-1)).to eq([]) end end describe '#page' do it 'should return array of pages when page_count > 0' do expect(subject.pages).to eq(pages) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
airspace-1.0.1 | spec/airspace/reader_spec.rb |