Sha256: 2e0d28426673b64caeaa66b7d6a4bb18b9b5d23dced0be89fac75d70f39ef9f4

Contents?: true

Size: 846 Bytes

Versions: 12

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe DHS::Record do
  let(:next_parameter) do
    { next: { href: 'http://example.com/users?from_user_id=100&limit=100' } }
  end
  let(:data_hash) { { items: 98.times.map { { foo: 'bar' } }, limit: 10 }.merge(next_parameter) }

  let(:data) do
    DHS::Data.new(data_hash, nil, DHS::Record)
  end

  let(:pagination) { DHS::Pagination::Link.new(data) }

  it 'responds to pages_left' do
    expect(pagination.pages_left).to eq(1)
  end

  it 'responds to pages_left?' do
    expect(pagination.pages_left?).to be true
  end

  context 'when there is no next' do
    let(:next_parameter) { {} }

    it 'responds to pages_left' do
      expect(pagination.pages_left).to eq(0)
    end

    it 'responds to pages_left?' do
      expect(pagination.pages_left?).to be false
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 spec/pagination/link/pages_left_spec.rb
dhs-1.5.0 spec/pagination/link/pages_left_spec.rb
dhs-1.4.2 spec/pagination/link/pages_left_spec.rb
dhs-1.4.1 spec/pagination/link/pages_left_spec.rb
dhs-1.4.0 spec/pagination/link/pages_left_spec.rb
dhs-1.3.0 spec/pagination/link/pages_left_spec.rb
dhs-1.2.0 spec/pagination/link/pages_left_spec.rb
dhs-1.1.0 spec/pagination/link/pages_left_spec.rb
dhs-1.0.3 spec/pagination/link/pages_left_spec.rb
dhs-1.0.2 spec/pagination/link/pages_left_spec.rb
dhs-1.0.1 spec/pagination/link/pages_left_spec.rb
dhs-1.0.0 spec/pagination/link/pages_left_spec.rb