nationbuilder-rb 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +16 -2
- data/VERSION +1 -1
- data/lib/nationbuilder.rb +1 -0
- data/lib/nationbuilder/client.rb +16 -12
- data/lib/nationbuilder/paginator.rb +22 -0
- data/nationbuilder-rb.gemspec +8 -3
- data/spec/fixtures/delete.yml +20 -20
- data/spec/fixtures/paginated_get_page2.yml +205 -0
- data/spec/fixtures/paginated_get_page3.yml +299 -0
- data/spec/fixtures/parametered_get.yml +46 -33
- data/spec/fixtures/parametered_post.yml +27 -21
- data/spec/nationbuilder_client_spec.rb +9 -13
- data/spec/nationbuilder_paginator_spec.rb +44 -0
- metadata +7 -2
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe NationBuilder::Client do
|
4
4
|
|
5
5
|
let(:client) do
|
6
|
-
NationBuilder::Client.new('
|
7
|
-
'
|
6
|
+
NationBuilder::Client.new('organizeralexandreschmitt',
|
7
|
+
'53920a524356034a065515a37650df2bd295971975d5742b9daa50eb8c7404d5')
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#endpoints' do
|
@@ -33,24 +33,22 @@ describe NationBuilder::Client do
|
|
33
33
|
:webhooks
|
34
34
|
])
|
35
35
|
end
|
36
|
-
|
37
36
|
end
|
38
37
|
|
39
38
|
describe '#base_url' do
|
40
39
|
|
41
40
|
it 'should contain the nation slug' do
|
42
|
-
client.base_url.should eq('https://
|
41
|
+
client.base_url.should eq('https://organizeralexandreschmitt.nationbuilder.com')
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
46
44
|
|
47
45
|
describe '#call' do
|
48
46
|
|
49
47
|
it 'should handle a parametered GET' do
|
50
48
|
VCR.use_cassette('parametered_get') do
|
51
|
-
response = client.call(:basic_pages, :index, site_slug: '
|
49
|
+
response = client.call(:basic_pages, :index, site_slug: 'organizeralexandreschmitt')
|
52
50
|
response['results'].each do |result|
|
53
|
-
result['site_slug'].should eq('
|
51
|
+
result['site_slug'].should eq('organizeralexandreschmitt')
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
@@ -58,9 +56,9 @@ describe NationBuilder::Client do
|
|
58
56
|
it 'should handle a parametered POST' do
|
59
57
|
params = {
|
60
58
|
person: {
|
61
|
-
email:
|
62
|
-
last_name:
|
63
|
-
first_name:
|
59
|
+
email: 'bob@example.com',
|
60
|
+
last_name: 'Smith',
|
61
|
+
first_name: 'Bob'
|
64
62
|
}
|
65
63
|
}
|
66
64
|
|
@@ -73,7 +71,7 @@ describe NationBuilder::Client do
|
|
73
71
|
|
74
72
|
it 'should handle a DELETE' do
|
75
73
|
params = {
|
76
|
-
id:
|
74
|
+
id: 21234
|
77
75
|
}
|
78
76
|
|
79
77
|
response = VCR.use_cassette('delete') do
|
@@ -82,7 +80,5 @@ describe NationBuilder::Client do
|
|
82
80
|
|
83
81
|
response.should eq({})
|
84
82
|
end
|
85
|
-
|
86
83
|
end
|
87
|
-
|
88
84
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Paginator do
|
4
|
+
|
5
|
+
let(:client) do
|
6
|
+
NationBuilder::Client.new('organizeralexandreschmitt',
|
7
|
+
'53920a524356034a065515a37650df2bd295971975d5742b9daa50eb8c7404d5')
|
8
|
+
end
|
9
|
+
let(:response) do
|
10
|
+
VCR.use_cassette('parametered_get') do
|
11
|
+
client.call(:basic_pages, :index, site_slug: 'organizeralexandreschmitt')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#pagination' do
|
16
|
+
before do
|
17
|
+
@page1 = Paginator.new(client, response)
|
18
|
+
@page2 = VCR.use_cassette('paginated_get_page2') { @page1.next }
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should check for next and prev page link' do
|
22
|
+
@page1.next?.should_not be_nil
|
23
|
+
@page1.prev?.should be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should return next page' do
|
27
|
+
VCR.use_cassette('paginated_get_page2') do
|
28
|
+
page2 = @page1.next
|
29
|
+
page2.body.should_not eq(@page1.body)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should return additional pages' do
|
34
|
+
VCR.use_cassette('paginated_get_page3') do
|
35
|
+
page3 = @page2.next
|
36
|
+
page3.body.should_not eq(@page2.body)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return nil if no prev page' do
|
41
|
+
@page1.prev.should be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nationbuilder-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Huie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- ".ruby-gemset"
|
109
109
|
- ".ruby-version"
|
110
110
|
- ".travis.yml"
|
111
|
+
- CHANGELOG.md
|
111
112
|
- Gemfile
|
112
113
|
- Gemfile.lock
|
113
114
|
- LICENSE.txt
|
@@ -120,14 +121,18 @@ files:
|
|
120
121
|
- lib/nationbuilder/client.rb
|
121
122
|
- lib/nationbuilder/endpoint.rb
|
122
123
|
- lib/nationbuilder/method.rb
|
124
|
+
- lib/nationbuilder/paginator.rb
|
123
125
|
- lib/nationbuilder/parameter.rb
|
124
126
|
- lib/nationbuilder/spec_parser.rb
|
125
127
|
- lib/nationbuilder/url.rb
|
126
128
|
- nationbuilder-rb.gemspec
|
127
129
|
- spec/fixtures/delete.yml
|
130
|
+
- spec/fixtures/paginated_get_page2.yml
|
131
|
+
- spec/fixtures/paginated_get_page3.yml
|
128
132
|
- spec/fixtures/parametered_get.yml
|
129
133
|
- spec/fixtures/parametered_post.yml
|
130
134
|
- spec/nationbuilder_client_spec.rb
|
135
|
+
- spec/nationbuilder_paginator_spec.rb
|
131
136
|
- spec/spec_helper.rb
|
132
137
|
homepage: http://github.com/3dna/nationbuilder-rb
|
133
138
|
licenses:
|