Sha256: 2773f75ffe00108a507d32eaae519b4febfdac803477c96b8be7b7eee2c65d59

Contents?: true

Size: 1.31 KB

Versions: 27

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::PagedRequest do
  it { described_class.constants.should include :FIRST_PAGE }
  it { described_class.constants.should include :PER_PAGE }
  it { described_class.constants.should include :NOT_FOUND }

  context 'page_request' do
    let(:path) { '/repos' }
    let(:client) { Github::Client }

    before do
      Github.stub(:api_client).and_return client
      client.stub(:get_request)
    end

    it 'sets default per_page when only custom page passed' do
      Github.stub_chain(:api_client, :per_page).and_return nil
      Github::PagedRequest.page_request path, {'page' => 3, 'per_page' => -1}
      Github::PagedRequest.page.should eq 3
      Github::PagedRequest.per_page.should eq 30
    end

    it 'sets default page when only custom per_page passed' do
      Github.stub_chain(:api_client, :page).and_return nil
      Github::PagedRequest.page_request path, {'per_page' => 33, 'page' => -1}
      Github::PagedRequest.page.should eq 1
      Github::PagedRequest.per_page.should eq 33
    end

    it 'sends get request with passed parameters' do
      Github::Client.should_receive(:get_request).
        with(path, 'page' => 2, 'per_page' => 33)
      Github::PagedRequest.page_request path, {'page' => 2, 'per_page' => 33}
    end
  end

end # Github::PagedRequest

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
github_api-0.8.11 spec/github/paged_request_spec.rb
github_api-0.8.10 spec/github/paged_request_spec.rb
github_api-0.8.9 spec/github/paged_request_spec.rb
github_api-0.8.8 spec/github/paged_request_spec.rb
github_api-0.8.7 spec/github/paged_request_spec.rb
github_api-0.8.6 spec/github/paged_request_spec.rb
github_api-0.8.5 spec/github/paged_request_spec.rb
github_api-0.8.4 spec/github/paged_request_spec.rb
github_api-0.8.3 spec/github/paged_request_spec.rb
github_api-0.8.2 spec/github/paged_request_spec.rb
github_api-0.8.1 spec/github/paged_request_spec.rb
github_api-0.8.0 spec/github/paged_request_spec.rb
github_api-0.7.2 spec/github/paged_request_spec.rb
github_api-0.7.1 spec/github/paged_request_spec.rb
github_api-0.7.0 spec/github/paged_request_spec.rb
github_api-0.6.5 spec/github/paged_request_spec.rb
github_api-0.6.4 spec/github/paged_request_spec.rb
github_api-0.6.3 spec/github/paged_request_spec.rb
github_api-0.6.2 spec/github/paged_request_spec.rb
github_api-0.6.1 spec/github/paged_request_spec.rb