zuck 2.1.0 → 3.0.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.
Files changed (40) hide show
  1. checksums.yaml +8 -8
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.markdown +7 -0
  4. data/VERSION +1 -1
  5. data/lib/zuck.rb +4 -4
  6. data/lib/zuck/facebook/ad_account.rb +0 -1
  7. data/lib/zuck/facebook/ad_creative.rb +0 -2
  8. data/lib/zuck/facebook/ad_group.rb +5 -8
  9. data/lib/zuck/facebook/ad_set.rb +1 -1
  10. data/spec/fixtures/a_single_account.yml +28 -28
  11. data/spec/fixtures/a_single_campaign.yml +14 -12
  12. data/spec/fixtures/a_single_group.yml +13 -11
  13. data/spec/fixtures/ad_interest_search_disney.yml +61 -35
  14. data/spec/fixtures/ad_interest_search_moviepilot.yml +59 -31
  15. data/spec/fixtures/ad_interest_search_nonexistant.yml +10 -8
  16. data/spec/fixtures/create_a_creative.yml +11 -9
  17. data/spec/fixtures/create_ad_campaign.yml +48 -40
  18. data/spec/fixtures/create_ad_group.yml +17 -13
  19. data/spec/fixtures/create_ad_set.yml +14 -12
  20. data/spec/fixtures/delete_ad_group.yml +11 -9
  21. data/spec/fixtures/delete_ad_set.yml +11 -9
  22. data/spec/fixtures/delete_campaign.yml +22 -18
  23. data/spec/fixtures/delete_creative.yml +11 -9
  24. data/spec/fixtures/find_a_single_group_and_update_it.yml +98 -64
  25. data/spec/fixtures/list_of_ad_accounts.yml +13 -11
  26. data/spec/fixtures/list_of_ad_campaigns.yml +13 -11
  27. data/spec/fixtures/list_of_ad_creatives.yml +10 -8
  28. data/spec/fixtures/list_of_ad_groups.yml +13 -11
  29. data/spec/fixtures/list_of_all_ad_creatives_of_account.yml +13 -11
  30. data/spec/fixtures/reach_for_invalid_interest.yml +29 -23
  31. data/spec/fixtures/reach_for_valid_keywords.yml +13 -11
  32. data/spec/fixtures/reach_for_valid_keywords_male_young.yml +13 -11
  33. data/spec/lib/zuck/facebook/ad_interest_spec.rb +1 -1
  34. data/spec/lib/zuck/facebook/targeting_spec_spec.rb +29 -25
  35. data/spec/lib/zuck_spec.rb +11 -6
  36. data/spec/spec_helper.rb +7 -1
  37. data/test_access_token +1 -1
  38. data/zuck.gemspec +4 -4
  39. metadata +3 -3
  40. data/.rvmrc +0 -1
@@ -11,7 +11,7 @@ describe Zuck::AdInterest do
11
11
 
12
12
  it "finds the best interest when no keyword with # is available" do
13
13
  VCR.use_cassette('ad_interest_search_moviepilot') do
14
- Zuck::AdInterest.best_guess(graph, 'moviepilot')[:name].should == 'moviepilot horror'
14
+ Zuck::AdInterest.best_guess(graph, 'moviepilot')[:name].should == 'Moviepilot'
15
15
  end
16
16
  end
17
17
 
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Zuck::TargetingSpec do
4
- let(:ad_account){ "2ijdsfoij" }
5
- let(:graph){ mock('koala') }
4
+ let(:ad_account) { "2ijdsfoij" }
5
+ let(:graph) { mock('koala') }
6
6
 
7
7
  describe "validating interests" do
8
8
 
9
- let(:valid_interest_result){ [{"name" => "foo", "valid" => true }] }
10
- let(:invalid_interest_result){ [] }
9
+ let(:valid_interest_result) { [{"name" => "foo", "valid" => true}] }
10
+ let(:invalid_interest_result) { [] }
11
11
 
12
12
 
13
13
  it "acknowledges valid interests" do
@@ -28,43 +28,43 @@ describe Zuck::TargetingSpec do
28
28
 
29
29
  describe "options given in spec" do
30
30
  it "accepts male as gender" do
31
- expect{
31
+ expect {
32
32
  Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'male')
33
33
  }.to_not raise_error
34
34
  end
35
35
 
36
36
  it "accepts male as gender for young people" do
37
- expect{
37
+ expect {
38
38
  Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'male', age_class: 'young')
39
39
  }.to_not raise_error
40
40
  end
41
41
 
42
42
  it "accepts male as gender for old people" do
43
- expect{
43
+ expect {
44
44
  Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'male', age_class: 'old')
45
45
  }.to_not raise_error
46
46
  end
47
47
 
48
48
  it "accepts without gender" do
49
- expect{
49
+ expect {
50
50
  Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}])
51
51
  }.to_not raise_error
52
52
  end
53
53
 
54
54
  it "accepts single keyword" do
55
- expect{
55
+ expect {
56
56
  Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interest: 'foo')
57
57
  }.to_not raise_error
58
58
  end
59
59
 
60
60
  it "does not accept invalid genders" do
61
- expect{
61
+ expect {
62
62
  Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'gemale')
63
63
  }.to raise_error("Gender can only be male or female")
64
64
  end
65
65
 
66
66
  it "does not accept invalid countries" do
67
- expect{
67
+ expect {
68
68
  z = Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['XX']}, interests: [{id: '123', name: 'foo'}], gender: 'female')
69
69
  z.send(:validate_spec)
70
70
  }.to raise_error('Invalid countrie(s): ["XX"]')
@@ -72,7 +72,7 @@ describe Zuck::TargetingSpec do
72
72
 
73
73
 
74
74
  it "does not accept targetings with neither :interests nor :connections" do
75
- expect{
75
+ expect {
76
76
  ts = Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, gender: 'female')
77
77
  ts.fetch_reach
78
78
  }.to raise_error("Need to set :interests or :connections")
@@ -80,14 +80,14 @@ describe Zuck::TargetingSpec do
80
80
  end
81
81
 
82
82
  describe "fetching reach" do
83
- let(:graph){ Koala::Facebook::API.new('CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh') }
84
- let(:ad_account){ 'act_1384977038406122' }
83
+ let(:graph) { Koala::Facebook::API.new(test_access_token) }
84
+ let(:ad_account) { test_account_id }
85
85
 
86
86
  it "bugs out when trying to use an invalid interest" do
87
87
  VCR.use_cassette('reach_for_invalid_interest') do
88
- spec = {geo_locations: {countries: ['us']}, interests: ['Eminem', 'invalidsssssssssssssss'] }
88
+ spec = {geo_locations: {countries: ['us']}, interests: ['Eminem', 'invalidsssssssssssssss']}
89
89
  ts = Zuck::TargetingSpec.new(graph, ad_account, spec)
90
- expect{
90
+ expect {
91
91
  ts.validate_interests
92
92
  }.to raise_error(Zuck::InvalidKeywordError, 'invalidsssssssssssssss')
93
93
  end
@@ -95,19 +95,23 @@ describe Zuck::TargetingSpec do
95
95
 
96
96
  it "works without gender or age" do
97
97
  VCR.use_cassette('reach_for_valid_keywords') do
98
- spec = {geo_locations: {countries: ['us']}, interests: [{id: '6003135347608', name: 'Eminem'}, {id: '6003504886186', name: 'Sting (musician)'}] }
98
+ spec = {geo_locations: {countries: ['us']}, interests: [{id: '6003135347608', name: 'Eminem'}, {id: '6003504886186', name: 'Sting (musician)'}]}
99
99
  ts = Zuck::TargetingSpec.new(graph, ad_account, spec)
100
- reach = ts.fetch_reach
101
- reach[:users].should == 37_00_0000
100
+ explain_error {
101
+ reach = ts.fetch_reach
102
+ reach[:users].should == 31_00_0000
103
+ }
102
104
  end
103
105
  end
104
106
 
105
107
  it "works with gender and age" do
106
108
  VCR.use_cassette('reach_for_valid_keywords_male_young') do
107
- spec = {geo_locations: {countries: ['us']}, interests: [{id: '6003504886186', name: 'Sting (musician)'}], gender: :female, age_class: :young }
109
+ spec = {geo_locations: {countries: ['us']}, interests: [{id: '6003504886186', name: 'Sting (musician)'}], gender: :female, age_class: :young}
108
110
  ts = Zuck::TargetingSpec.new(graph, ad_account, spec)
109
- reach = ts.fetch_reach
110
- reach[:users].should == 16_000
111
+ explain_error {
112
+ reach = ts.fetch_reach
113
+ reach[:users].should == 63_000
114
+ }
111
115
  end
112
116
  end
113
117
 
@@ -122,9 +126,9 @@ describe Zuck::TargetingSpec do
122
126
  end
123
127
 
124
128
  describe "Batch processing" do
125
- let(:graph){ Koala::Facebook::API.new(test_access_token) }
126
- let(:ad_account){ 'act_10150585630710217' }
127
- let(:spec_mock){ mock(fetch_reach: {some: :data}) }
129
+ let(:graph) { Koala::Facebook::API.new(test_access_token) }
130
+ let(:ad_account) { test_account_id }
131
+ let(:spec_mock) { mock(fetch_reach: {some: :data}) }
128
132
 
129
133
  it "fetches each reach" do
130
134
  requests = [{some: :thing}] * 51
@@ -9,7 +9,7 @@ describe Zuck::FbObject do
9
9
 
10
10
 
11
11
  let(:graph) { Zuck.graph }
12
- let(:account_id) { "act_367106653" }
12
+ let(:account_id) { test_account_id }
13
13
  let(:account) { Zuck::AdAccount.new(graph, {id: account_id}) }
14
14
 
15
15
  describe "talking to facebook" do
@@ -52,8 +52,9 @@ describe Zuck::FbObject do
52
52
  it "an ad set" do
53
53
  VCR.use_cassette('create_ad_set') do
54
54
  o = {
55
- bid_type: 'CPC',
56
- bid_info: "{'CLICKS': 1}",
55
+ bid_amount: 1,
56
+ billing_event: 'IMPRESSIONS',
57
+ optimization_goal: 'REACH',
57
58
  name: 'bloody ad set',
58
59
  campaign_status: 'PAUSED',
59
60
  daily_budget: 100,
@@ -88,13 +89,14 @@ describe Zuck::FbObject do
88
89
  o = {
89
90
  name: "Rap like me",
90
91
  # targeting: '{"geo_locations": {"countries":["US"]}}',
91
- objective: 'WEBSITE_CLICKS',
92
+ # objective: 'WEBSITE_CLICKS',
93
+ bid_amount: 5,
92
94
  creative: '{"creative_id": '+creative.id+'}'
93
95
  }
94
96
  explain_error {
95
97
  group = set.create_ad_group(o)
96
98
  group.name.should == "Rap like me"
97
- group['bid_type'].should == 'CPC'
99
+ group['bid_type'].should == 'ABSOLUTE_OCPM'
98
100
  }
99
101
  end
100
102
  end
@@ -193,7 +195,9 @@ describe Zuck::FbObject do
193
195
 
194
196
  it "a creative" do
195
197
  VCR.use_cassette('delete_creative') do
196
- creative.destroy.should be_true
198
+ explain_error {
199
+ creative.destroy.should be_true
200
+ }
197
201
  end
198
202
  end
199
203
 
@@ -203,6 +207,7 @@ describe Zuck::FbObject do
203
207
  act_campaign.destroy.should be_true
204
208
  end
205
209
  end
210
+
206
211
  end
207
212
  end
208
213
  end
@@ -28,6 +28,8 @@ RSpec.configure do |config|
28
28
 
29
29
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
30
30
 
31
+ # enable if you have issues with the api and need to see queries directly
32
+ # Koala::Utils.level = Logger::DEBUG
31
33
  end
32
34
 
33
35
  module TestResponseExtensions
@@ -41,7 +43,11 @@ module TestResponseExtensions
41
43
  end
42
44
 
43
45
  def test_access_token
44
- @test_access_token ||= File.read("test_access_token")
46
+ @test_access_token ||= File.read("test_access_token").split("|")[1]
47
+ end
48
+
49
+ def test_account_id
50
+ @test_account_id ||= File.read("test_access_token").split("|")[0]
45
51
  end
46
52
 
47
53
  def explain_error(&block)
@@ -1 +1 @@
1
- FAKEACCESSTOKEN
1
+ act_367106653|DUMMY_TOKEN
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: zuck 2.1.0 ruby lib
5
+ # stub: zuck 3.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "zuck"
9
- s.version = "2.1.0"
9
+ s.version = "3.0.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Jannis Hermanns"]
14
- s.date = "2015-04-15"
14
+ s.date = "2015-09-22"
15
15
  s.description = "This gem allows to easily access facebook's ads api in ruby. See https://developers.facebook.com/docs/reference/ads-api/"
16
16
  s.email = "jannis@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  "README.markdown"
20
20
  ]
21
21
  s.files = [
22
- ".rvmrc",
22
+ ".ruby-version",
23
23
  ".travis.yml",
24
24
  ".yardopts",
25
25
  "CHANGELOG.markdown",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuck
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jannis Hermanns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rvm
@@ -284,7 +284,7 @@ extra_rdoc_files:
284
284
  - LICENSE.txt
285
285
  - README.markdown
286
286
  files:
287
- - .rvmrc
287
+ - .ruby-version
288
288
  - .travis.yml
289
289
  - .yardopts
290
290
  - CHANGELOG.markdown
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm --create use ruby-1.9.3@zuck