Sha256: 0b70983ad743fe69ba190b1f36fda9b8948ffad021073630e2711cc313fc207e

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Paginator do

  let(:client) do
    NationBuilder::Client.new('organizeralexandreschmitt',
                              '53920a524356034a065515a37650df2bd295971975d5742b9daa50eb8c7404d5')
  end
  let(:response) do
    VCR.use_cassette('parametered_get') do
      client.call(:basic_pages, :index, site_slug: 'organizeralexandreschmitt')
    end
  end

  describe '#pagination' do
    before do
      @page1 = Paginator.new(client, response)
      @page2 = VCR.use_cassette('paginated_get_page2') { @page1.next }
    end

    it 'should check for next and prev page link' do
      @page1.next?.should_not be_nil
      @page1.prev?.should be_nil
    end

    it 'should return next page' do
      VCR.use_cassette('paginated_get_page2') do
        page2 = @page1.next
        page2.body.should_not eq(@page1.body)
      end
    end

    it 'should return additional pages' do
      VCR.use_cassette('paginated_get_page3') do
        page3 = @page2.next
        page3.body.should_not eq(@page2.body)
      end
    end

    it 'should return nil if no prev page' do
      @page1.prev.should be_nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nationbuilder-rb-1.1.0 spec/nationbuilder_paginator_spec.rb