Sha256: 8994de281b04e4b637058f934969728b85f9f02bae37dc5fea62c77d2d4aaa24
Contents?: true
Size: 1.87 KB
Versions: 13
Compression:
Stored size: 1.87 KB
Contents
require 'spec_helper' describe Locomotive::Steam::Models::Pager do let(:page) { 1 } let(:per_page) { 2 } let(:source) { ['MongoDB', 'Rails', 'Liquid', 'Rack', 'Devise'] } let(:pager) { described_class.new(source, page, per_page) } describe '#collection' do subject { pager.collection } it { is_expected.to eq ['MongoDB', 'Rails'] } describe 'last page' do let(:page) { 3 } it { is_expected.to eq ['Devise'] } end describe 'per_page is 1' do let(:per_page) { 1 } it { is_expected.to eq ['MongoDB'] } end describe 'per_page is greater than the number of total entries' do let(:per_page) { 10 } it { is_expected.to eq ['MongoDB', 'Rails', 'Liquid', 'Rack', 'Devise'] } end describe 'page is > to the total number of pages' do let(:page) { 4 } it { is_expected.to eq [] } end describe 'page is a negative number' do let(:page) { -3 } it { is_expected.to eq ['MongoDB', 'Rails'] } end describe 'page is a string' do let(:page) { ''.to_i } it { is_expected.to eq ['MongoDB', 'Rails'] } end end describe '#previous_page' do subject { pager.previous_page } it { is_expected.to eq nil } describe 'another page' do let(:page) { 2 } it { is_expected.to eq 1 } end end describe '#next_page' do subject { pager.next_page } it { is_expected.to eq 2 } describe 'another page' do let(:page) { 3 } it { is_expected.to eq nil } end end describe '#to_liquid' do subject { pager.to_liquid } it do is_expected.to eq({ collection: ['MongoDB', 'Rails'], current_page: 1, per_page: 2, previous_page: nil, next_page: 2, total_entries: 5, total_pages: 3 }) end end end
Version data entries
13 entries across 13 versions & 1 rubygems