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.
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe NationBuilder::Client do
4
4
 
5
5
  let(:client) do
6
- NationBuilder::Client.new('dh',
7
- '6ed3ab9395daf0e3e39098761e85e8e703aa84921c5c1e32637f6984944cf1f2')
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://dh.nationbuilder.com')
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: 'dh')
49
+ response = client.call(:basic_pages, :index, site_slug: 'organizeralexandreschmitt')
52
50
  response['results'].each do |result|
53
- result['site_slug'].should eq('dh')
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: "bob@example.com",
62
- last_name: "Smith",
63
- first_name: "Bob"
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: 24,
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.0.0
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-01-06 00:00:00.000000000 Z
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: