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.
- checksums.yaml +8 -8
- data/.ruby-version +1 -0
- data/CHANGELOG.markdown +7 -0
- data/VERSION +1 -1
- data/lib/zuck.rb +4 -4
- data/lib/zuck/facebook/ad_account.rb +0 -1
- data/lib/zuck/facebook/ad_creative.rb +0 -2
- data/lib/zuck/facebook/ad_group.rb +5 -8
- data/lib/zuck/facebook/ad_set.rb +1 -1
- data/spec/fixtures/a_single_account.yml +28 -28
- data/spec/fixtures/a_single_campaign.yml +14 -12
- data/spec/fixtures/a_single_group.yml +13 -11
- data/spec/fixtures/ad_interest_search_disney.yml +61 -35
- data/spec/fixtures/ad_interest_search_moviepilot.yml +59 -31
- data/spec/fixtures/ad_interest_search_nonexistant.yml +10 -8
- data/spec/fixtures/create_a_creative.yml +11 -9
- data/spec/fixtures/create_ad_campaign.yml +48 -40
- data/spec/fixtures/create_ad_group.yml +17 -13
- data/spec/fixtures/create_ad_set.yml +14 -12
- data/spec/fixtures/delete_ad_group.yml +11 -9
- data/spec/fixtures/delete_ad_set.yml +11 -9
- data/spec/fixtures/delete_campaign.yml +22 -18
- data/spec/fixtures/delete_creative.yml +11 -9
- data/spec/fixtures/find_a_single_group_and_update_it.yml +98 -64
- data/spec/fixtures/list_of_ad_accounts.yml +13 -11
- data/spec/fixtures/list_of_ad_campaigns.yml +13 -11
- data/spec/fixtures/list_of_ad_creatives.yml +10 -8
- data/spec/fixtures/list_of_ad_groups.yml +13 -11
- data/spec/fixtures/list_of_all_ad_creatives_of_account.yml +13 -11
- data/spec/fixtures/reach_for_invalid_interest.yml +29 -23
- data/spec/fixtures/reach_for_valid_keywords.yml +13 -11
- data/spec/fixtures/reach_for_valid_keywords_male_young.yml +13 -11
- data/spec/lib/zuck/facebook/ad_interest_spec.rb +1 -1
- data/spec/lib/zuck/facebook/targeting_spec_spec.rb +29 -25
- data/spec/lib/zuck_spec.rb +11 -6
- data/spec/spec_helper.rb +7 -1
- data/test_access_token +1 -1
- data/zuck.gemspec +4 -4
- metadata +3 -3
- 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 == '
|
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){
|
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(
|
84
|
-
let(:ad_account){
|
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
|
-
|
101
|
-
|
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
|
-
|
110
|
-
|
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){
|
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
|
data/spec/lib/zuck_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Zuck::FbObject do
|
|
9
9
|
|
10
10
|
|
11
11
|
let(:graph) { Zuck.graph }
|
12
|
-
let(:account_id) {
|
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
|
-
|
56
|
-
|
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 == '
|
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
|
-
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -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)
|
data/test_access_token
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
act_367106653|DUMMY_TOKEN
|
data/zuck.gemspec
CHANGED
@@ -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
|
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 = "
|
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-
|
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
|
-
".
|
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:
|
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-
|
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
|
-
- .
|
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
|