forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage_links_spec.rb
More file actions
35 lines (26 loc) · 1.3 KB
/
page_links_spec.rb
File metadata and controls
35 lines (26 loc) · 1.3 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
# encoding: utf-8
require 'spec_helper'
describe Github::PageLinks do
let(:link) {
"<https://api.github.com/users/wycats/repos?page=4&per_page=20>; rel=\"next\", <https://api.github.com/users/wycats/repos?page=6&per_page=20>; rel=\"last\", <https://api.github.com/users/wycats/repos?page=1&per_page=20>; rel=\"first\", <https://api.github.com/users/wycats/repos?page=2&per_page=20>; rel=\"prev\""
}
let(:response_headers) { { 'Link' => link } }
let(:first) { "https://api.github.com/users/wycats/repos?page=1&per_page=20" }
let(:last) { "https://api.github.com/users/wycats/repos?page=6&per_page=20" }
let(:prev) { "https://api.github.com/users/wycats/repos?page=2&per_page=20" }
let(:nexxt) { "https://api.github.com/users/wycats/repos?page=4&per_page=20" }
context 'build page links instance' do
it 'parses first link successfully' do
Github::PageLinks.new(response_headers).first.should eql first
end
it 'parses last link successfully' do
Github::PageLinks.new(response_headers).last.should eql last
end
it 'parses next link successfully' do
Github::PageLinks.new(response_headers).next.should eql nexxt
end
it 'parses prev link successfully' do
Github::PageLinks.new(response_headers).prev.should eql prev
end
end
end # Github::PageLinks