Sha256: fed8130e35cc3c05b3a22879b8be0793584add2dcddc724a88d8acf21888e3fb

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

module Footrest
  describe Pagination do

    describe "#on_complete" do
      let(:response) {
        {
          response_headers: {
            link: "<current_link>; rel=\"current\",<next_link>; rel=\"next\",<prev_link>; rel=\"prev\",<first_link>; rel=\"first\",<last_link>; rel=\"last\""
          }
        }
      }

      before do
        Pagination.new.on_complete(response)
      end

      it 'captures prev, next, first, last, and current page links as response headers' do
        %w(prev next first last current).each do |page|
          expect(response["#{page}_page".to_sym]).to eq("#{page}_link")
        end
      end

      it 'must capture the pagination links in an object at the pagination_links key' do
        expect(response[:pagination_links]).to be_a Pagination::Links
      end

      it 'must capture all of the link types in the Links object' do
        obj = response[:pagination_links]
        %w(prev next first last current).each do |page|
          expect(obj.public_send(page)).to eq("#{page}_link")
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
footrest-0.5.8 spec/footrest/pagination_spec.rb
footrest-0.5.7 spec/footrest/pagination_spec.rb
footrest-0.5.6 spec/footrest/pagination_spec.rb
footrest-0.5.5 spec/footrest/pagination_spec.rb
footrest-0.5.3 spec/footrest/pagination_spec.rb
footrest-0.5.2 spec/footrest/pagination_spec.rb
footrest-0.5.1 spec/footrest/pagination_spec.rb
footrest-0.5.0 spec/footrest/pagination_spec.rb