mailchimp_api_v3 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/lib/mailchimp_api_v3/client/remote.rb +12 -8
  4. data/lib/mailchimp_api_v3/collection.rb +1 -1
  5. data/lib/mailchimp_api_v3/collection/paging.rb +1 -1
  6. data/lib/mailchimp_api_v3/instance.rb +5 -1
  7. data/lib/mailchimp_api_v3/version.rb +1 -1
  8. data/spec/fixtures/cassettes/account.yml +92 -0
  9. data/spec/fixtures/cassettes/client.yml +223 -0
  10. data/spec/fixtures/cassettes/exception.yml +179 -0
  11. data/spec/fixtures/cassettes/interest.yml +384 -0
  12. data/spec/fixtures/cassettes/interest_categories.yml +637 -0
  13. data/spec/fixtures/cassettes/interest_category.yml +389 -0
  14. data/spec/fixtures/cassettes/interests.yml +723 -0
  15. data/spec/fixtures/cassettes/list.yml +176 -0
  16. data/spec/fixtures/cassettes/lists.yml +47 -0
  17. data/spec/fixtures/cassettes/mailchimp.yml +6 -886
  18. data/spec/fixtures/cassettes/member.yml +267 -0
  19. data/spec/fixtures/cassettes/members.yml +17 -6
  20. data/spec/mailchimp_api_v3/account_spec.rb +1 -1
  21. data/spec/mailchimp_api_v3/client_spec.rb +1 -1
  22. data/spec/mailchimp_api_v3/exception_spec.rb +1 -1
  23. data/spec/mailchimp_api_v3/interest_categories_spec.rb +21 -33
  24. data/spec/mailchimp_api_v3/interest_category_spec.rb +7 -7
  25. data/spec/mailchimp_api_v3/interest_spec.rb +9 -6
  26. data/spec/mailchimp_api_v3/interests_spec.rb +24 -28
  27. data/spec/mailchimp_api_v3/list_spec.rb +1 -1
  28. data/spec/mailchimp_api_v3/lists_spec.rb +1 -1
  29. data/spec/mailchimp_api_v3/member_spec.rb +4 -3
  30. data/spec/mailchimp_api_v3/members_spec.rb +1 -1
  31. data/spec/support/vcr_setup.rb +1 -1
  32. metadata +23 -4
@@ -2,21 +2,24 @@
2
2
  require 'spec_helper'
3
3
  require 'mailchimp_api_v3'
4
4
 
5
- describe Mailchimp::List::InterestCategory::Interest, vcr: { cassette_name: 'mailchimp' } do
5
+ describe Mailchimp::List::InterestCategory::Interest, vcr: { cassette_name: 'interest' } do
6
6
  let(:lists) { Mailchimp.connect.lists }
7
7
  let(:list) { lists.first }
8
- let(:interest_category) { list.interest_categories.first }
9
- let(:interest) { interest_category.interests.first }
8
+ let(:title) { 'Days' }
9
+ let(:interest_category) { list.interest_categories.create 'title' => title, 'type' => 'checkboxes' }
10
+ let(:name) { 'Monday' }
11
+ let(:interest) { interest_category.interests.create name: name }
10
12
 
11
13
  it 'is the expected class' do
12
14
  expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
13
15
  end
14
16
 
15
17
  it 'has a name' do
16
- expect(interest.name).to eq 'red'
18
+ expect(interest.name).to eq name
17
19
  end
18
20
 
19
- it 'has an id' do
20
- expect(interest.id).to eq '3fbb48c043'
21
+ it 'deletes an instance' do
22
+ interest2 = interest_category.interests.create name: 'Tuesday'
23
+ expect { interest2.delete }.to change { interest_category.interests.count }.by(-1)
21
24
  end
22
25
  end
@@ -2,47 +2,43 @@
2
2
  require 'spec_helper'
3
3
  require 'mailchimp_api_v3'
4
4
 
5
- describe Mailchimp::List::InterestCategory::Interests, vcr: { cassette_name: 'mailchimp' } do
5
+ describe Mailchimp::List::InterestCategory::Interests, vcr: { cassette_name: 'interests' } do
6
6
  let(:list) { Mailchimp.connect.lists.first }
7
- let(:interest_category) { list.interest_categories.first }
7
+ let(:title) { 'Days' }
8
+ let(:interest_category) { list.interest_categories.create 'title' => title, 'type' => 'checkboxes' }
8
9
  let(:interests) { interest_category.interests }
9
10
 
10
11
  it 'is the expected class' do
11
12
  expect(interests).to be_a Mailchimp::List::InterestCategory::Interests
12
13
  end
13
14
 
14
- it 'has a count' do
15
- expect(interests.count).to eq 1
16
- end
17
-
18
- context 'adding a new instance' do
19
- context '#create' do
20
- it 'can add a new instance' do
21
- data = { 'name' => 'Green' }
22
- interest = interests.create data
23
- expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
24
- expect(interest.name).to eq 'Green'
25
- end
15
+ context 'adding and deleting' do
16
+ context '#create, #find_by, #delete, #first_or_create' do
17
+ it 'can add and delete a new instance' do
18
+ name = 'Monday'
19
+ data = { 'name' => name }
26
20
 
27
- it 'fails adding an instance with the same details' do
28
- data = { 'name' => 'Red' }
21
+ # #create
22
+ expect { interests.create data }.to change { interest_category.interests.count }.by(1)
29
23
  expect { interests.create data }.to raise_error Mailchimp::Exception::Duplicate
30
- end
31
- end
32
24
 
33
- context '#first_or_create' do
34
- it 'finds an instance with the same details' do
35
- data = { 'name' => 'Red' }
36
- interest = interests.first_or_create data
25
+ # #find_by
26
+ interest = interest_category.interests.find_by name: name
37
27
  expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
38
- expect(interest.name).to eq 'red' # Note case
39
- end
28
+ expect(interest.name).to eq name
29
+
30
+ # #first_or_create finds the same instance
31
+ interest2 = interest_category.interests.first_or_create name: name
32
+ expect(interest.id).to eq(interest2.id)
40
33
 
41
- it 'creates a new instance if one does not yet exist' do
42
- data = { 'name' => 'Amber' }
34
+ # #delete
35
+ expect { interest.delete }.to change { interest_category.interests.count }.by(-1)
36
+
37
+ # #first_or_create creates a new instance
38
+ name = 'Tuesday'
39
+ data = { 'name' => name }
43
40
  interest = interests.first_or_create data
44
- expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
45
- expect(interest.name).to eq 'Amber'
41
+ expect(interest.name).to eq name
46
42
  end
47
43
  end
48
44
  end
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
  require 'mailchimp_api_v3'
4
4
 
5
- describe Mailchimp::List, vcr: { cassette_name: 'mailchimp' } do
5
+ describe Mailchimp::List, vcr: { cassette_name: 'list' } do
6
6
  let(:lists) { Mailchimp.connect.lists }
7
7
  let(:list) { lists.first }
8
8
 
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
  require 'mailchimp_api_v3'
4
4
 
5
- describe Mailchimp::Lists, vcr: { cassette_name: 'mailchimp' } do
5
+ describe Mailchimp::Lists, vcr: { cassette_name: 'lists' } do
6
6
  let(:lists) { Mailchimp.connect.lists }
7
7
 
8
8
  it 'is the expected class' do
@@ -2,17 +2,18 @@
2
2
  require 'spec_helper'
3
3
  require 'mailchimp_api_v3'
4
4
 
5
- describe Mailchimp::List::Member, vcr: { cassette_name: 'mailchimp' } do
5
+ describe Mailchimp::List::Member, vcr: { cassette_name: 'member' } do
6
6
  let(:lists) { Mailchimp.connect.lists }
7
7
  let(:list) { lists.first }
8
- let(:member) { list.members.first }
8
+ let(:name) { 'Ann Example' }
9
+ let(:member) { list.members.first_or_create name: name, email_address: 'ann@sayers.cc' }
9
10
 
10
11
  it 'is the expected class' do
11
12
  expect(member).to be_a Mailchimp::List::Member
12
13
  end
13
14
 
14
15
  it 'has a name' do
15
- expect(member.name).to eq 'Ann Example'
16
+ expect(member.name).to eq name
16
17
  end
17
18
 
18
19
  it 'has an id' do
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
  require 'mailchimp_api_v3'
4
4
 
5
- describe Mailchimp::List::Members, vcr: { cassette_name: 'members' } do
5
+ describe Mailchimp::List::Members, vcr: { cassette_name: 'members', allow_playback_repeats: true } do
6
6
  let(:page_size) { 10 }
7
7
  let(:member_count) { 37 }
8
8
  let(:list) { Mailchimp.connect.lists.first }
@@ -10,6 +10,6 @@ VCR.configure do |c|
10
10
  erb: true,
11
11
  decode_compressed_response: true,
12
12
  match_requests_on: [:method, :uri, :headers, :body],
13
- allow_playback_repeats: true
13
+ allow_playback_repeats: false
14
14
  }
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailchimp_api_v3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xenapto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -237,7 +237,17 @@ files:
237
237
  - lib/mailchimp_api_v3/member.rb
238
238
  - lib/mailchimp_api_v3/version.rb
239
239
  - mailchimp_api_v3.gemspec
240
+ - spec/fixtures/cassettes/account.yml
241
+ - spec/fixtures/cassettes/client.yml
242
+ - spec/fixtures/cassettes/exception.yml
243
+ - spec/fixtures/cassettes/interest.yml
244
+ - spec/fixtures/cassettes/interest_categories.yml
245
+ - spec/fixtures/cassettes/interest_category.yml
246
+ - spec/fixtures/cassettes/interests.yml
247
+ - spec/fixtures/cassettes/list.yml
248
+ - spec/fixtures/cassettes/lists.yml
240
249
  - spec/fixtures/cassettes/mailchimp.yml
250
+ - spec/fixtures/cassettes/member.yml
241
251
  - spec/fixtures/cassettes/members.yml
242
252
  - spec/mailchimp_api_v3/account_spec.rb
243
253
  - spec/mailchimp_api_v3/client_spec.rb
@@ -274,12 +284,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
284
  version: '0'
275
285
  requirements: []
276
286
  rubyforge_project:
277
- rubygems_version: 2.4.8
287
+ rubygems_version: 2.4.6
278
288
  signing_key:
279
289
  specification_version: 4
280
290
  summary: 'Example: mailchimp.lists("My first list").member("ann@example.com")'
281
291
  test_files:
292
+ - spec/fixtures/cassettes/account.yml
293
+ - spec/fixtures/cassettes/client.yml
294
+ - spec/fixtures/cassettes/exception.yml
295
+ - spec/fixtures/cassettes/interest.yml
296
+ - spec/fixtures/cassettes/interest_categories.yml
297
+ - spec/fixtures/cassettes/interest_category.yml
298
+ - spec/fixtures/cassettes/interests.yml
299
+ - spec/fixtures/cassettes/list.yml
300
+ - spec/fixtures/cassettes/lists.yml
282
301
  - spec/fixtures/cassettes/mailchimp.yml
302
+ - spec/fixtures/cassettes/member.yml
283
303
  - spec/fixtures/cassettes/members.yml
284
304
  - spec/mailchimp_api_v3/account_spec.rb
285
305
  - spec/mailchimp_api_v3/client_spec.rb
@@ -296,4 +316,3 @@ test_files:
296
316
  - spec/spec_helper.rb
297
317
  - spec/support/api_key.rb
298
318
  - spec/support/vcr_setup.rb
299
- has_rdoc: