forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaged_request_spec.rb
More file actions
45 lines (33 loc) · 1.17 KB
/
paged_request_spec.rb
File metadata and controls
45 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# encoding: utf-8
require 'spec_helper'
describe Github::PagedRequest, '#page_request' do
let(:current_api) { Github::Repos.new }
let(:path) { "/repositories/"}
let(:klass) {
klass = Class.new do
include Github::PagedRequest
end
}
subject(:instance) { klass.new }
before {
instance.stub(:current_api).and_return current_api
}
it { klass.constants.should include :FIRST_PAGE }
it { klass.constants.should include :PER_PAGE }
it { klass.constants.should include :NOT_FOUND }
it { should respond_to(:page_request) }
it 'calls get_request on api current instance' do
current_api.should_receive(:get_request).with(path, {})
instance.page_request(path)
end
it 'sets default per_page when only custom page passed' do
current_api.should_receive(:get_request).
with(path, {'page' => 3, 'per_page' => 30})
instance.page_request(path, {'page' => 3, 'per_page' => -1})
end
it 'sets default page when only custom per_page passed' do
current_api.should_receive(:get_request).
with(path, {'page' => 1, 'per_page' => 33})
instance.page_request(path, {'page' => -1, 'per_page' => 33})
end
end # Github::PagedRequest