zuck 0.1.0 → 0.2.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 (36) hide show
  1. data/CHANGELOG.markdown +4 -0
  2. data/README.markdown +35 -0
  3. data/VERSION +1 -1
  4. data/lib/zuck/facebook/ad_account.rb +8 -5
  5. data/lib/zuck/facebook/ad_campaign.rb +0 -1
  6. data/lib/zuck/facebook/ad_creative.rb +11 -10
  7. data/lib/zuck/facebook/ad_group.rb +5 -7
  8. data/lib/zuck/fb_object/hash_delegator.rb +5 -1
  9. data/lib/zuck/fb_object/helpers.rb +1 -1
  10. data/lib/zuck/fb_object/read.rb +0 -35
  11. data/spec/fixtures/a_single_account.yml +32 -57
  12. data/spec/fixtures/a_single_campaign.yml +12 -12
  13. data/spec/fixtures/a_single_group.yml +48 -0
  14. data/spec/fixtures/ad_keyword_search_disney.yml +12 -12
  15. data/spec/fixtures/{ad_keyword_search_steve_carell.yml → ad_keyword_search_moviepilot.yml} +8 -9
  16. data/spec/fixtures/ad_keyword_search_nonexistant.yml +5 -5
  17. data/spec/fixtures/create_ad_campaign.yml +12 -15
  18. data/spec/fixtures/create_ad_group.yml +15 -14
  19. data/spec/fixtures/delete_ad_group.yml +11 -15
  20. data/spec/fixtures/find_a_single_group_and_update_it.yml +224 -0
  21. data/spec/fixtures/list_of_ad_accounts.yml +26 -23
  22. data/spec/fixtures/list_of_ad_campaigns.yml +23 -24
  23. data/spec/fixtures/list_of_ad_creatives.yml +13 -15
  24. data/spec/fixtures/list_of_ad_groups.yml +62 -31
  25. data/spec/fixtures/list_of_all_ad_creatives_of_account.yml +41 -34
  26. data/spec/fixtures/reach_for_invalid_keyword.yml +9 -56
  27. data/spec/fixtures/reach_for_valid_keywords.yml +11 -56
  28. data/spec/fixtures/reach_for_valid_keywords_male_young.yml +11 -56
  29. data/spec/lib/zuck/facebook/ad_keyword_spec.rb +3 -3
  30. data/spec/lib/zuck/facebook/targeting_spec_spec.rb +4 -4
  31. data/spec/lib/zuck/fb_object/helpers_spec.rb +3 -2
  32. data/spec/lib/zuck_spec.rb +17 -24
  33. data/spec/spec_helper.rb +3 -0
  34. data/zuck.gemspec +5 -4
  35. metadata +6 -5
  36. data/spec/fixtures/find_a_single_campaign_and_update_it.yml +0 -247
@@ -2,17 +2,17 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://graph.facebook.com/search?access_token=AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD&keyword_list=Eminem,invalidsssssssssssssss&type=adkeywordvalid
5
+ uri: https://graph.facebook.com/search?access_token=CAAEvJ5vzhl8BAH8aCPOx0Ft9uNB147TF8weJ8hK0g7YVDRWU4eEih7tEKdJgmfk0vABZClZACJbEzyhSMbiShL6RpsfkZASfX1C9nv1AlFvjJajflqkyYZAlpE2edT0FJHjdh4NFg0ZCt0sBgq0kZABtKsjuU18aMURLE7rjKHR4X8NkXBUafg1T4uZARRNqboZD&keyword_list=Eminem,invalidsssssssssssssss&type=adkeywordvalid
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
+ User-Agent:
11
+ - Faraday v0.8.7
10
12
  Accept-Encoding:
11
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
14
  Accept:
13
15
  - ! '*/*'
14
- User-Agent:
15
- - Ruby
16
16
  response:
17
17
  status:
18
18
  code: 200
@@ -23,7 +23,7 @@ http_interactions:
23
23
  Cache-Control:
24
24
  - private, no-cache, no-store, must-revalidate
25
25
  Content-Type:
26
- - text/javascript; charset=UTF-8
26
+ - application/json; charset=UTF-8
27
27
  Etag:
28
28
  - ! '"1b6af91a08d48aeee5ffa0cf3437f38b61281b68"'
29
29
  Expires:
@@ -31,11 +31,11 @@ http_interactions:
31
31
  Pragma:
32
32
  - no-cache
33
33
  X-Fb-Rev:
34
- - '698469'
34
+ - '934677'
35
35
  X-Fb-Debug:
36
- - 7so4yUGhkG2hb0KiZDAFNlrgtEmcB0xQ9Xilxl/LfRw=
36
+ - J8DeY1E4Yqw7bJX0tlNMHLA1W2i+1busrhuPm8oG1vg=
37
37
  Date:
38
- - Wed, 19 Dec 2012 14:36:48 GMT
38
+ - Thu, 12 Sep 2013 13:21:34 GMT
39
39
  Connection:
40
40
  - keep-alive
41
41
  Content-Length:
@@ -44,52 +44,5 @@ http_interactions:
44
44
  encoding: US-ASCII
45
45
  string: ! '{"data":[{"name":"Eminem","valid":true,"id":6003170652434},{"name":"invalidsssssssssssssss","valid":false}]}'
46
46
  http_version:
47
- recorded_at: Wed, 19 Dec 2012 14:36:48 GMT
48
- - request:
49
- method: get
50
- uri: https://graph.facebook.com/act_10150585630710217/reachestimate?access_token=AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD&targeting_spec=%7B%22countries%22:%5B%22US%22%5D,%22keywords%22:%5B%22Eminem%22,%22invalidsssssssssssssss%22%5D,%22age_min%22:13,%22connections%22:%5B%5D%7D
51
- body:
52
- encoding: US-ASCII
53
- string: ''
54
- headers:
55
- Accept-Encoding:
56
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
- Accept:
58
- - ! '*/*'
59
- User-Agent:
60
- - Ruby
61
- response:
62
- status:
63
- code: 400
64
- message: Bad Request
65
- headers:
66
- Access-Control-Allow-Origin:
67
- - ! '*'
68
- Cache-Control:
69
- - no-store
70
- Content-Type:
71
- - text/javascript; charset=UTF-8
72
- Expires:
73
- - Sat, 01 Jan 2000 00:00:00 GMT
74
- Pragma:
75
- - no-cache
76
- Www-Authenticate:
77
- - ! 'OAuth "Facebook Platform" "invalid_token" "Error validating access token:
78
- Session has expired at unix time 1355932800. The current unix time is 1355934833."'
79
- X-Fb-Rev:
80
- - '698469'
81
- X-Fb-Debug:
82
- - Kkjlojh5eu19FxaW5yu6N5A+5xmmbKyfKsCpa+y2eOc=
83
- Date:
84
- - Wed, 19 Dec 2012 16:33:53 GMT
85
- Connection:
86
- - keep-alive
87
- Content-Length:
88
- - '191'
89
- body:
90
- encoding: US-ASCII
91
- string: ! '{"error":{"message":"Error validating access token: Session has expired
92
- at unix time 1355932800. The current unix time is 1355934833.","type":"OAuthException","code":190,"error_subcode":463}}'
93
- http_version:
94
- recorded_at: Wed, 19 Dec 2012 16:33:53 GMT
95
- recorded_with: VCR 2.2.4
47
+ recorded_at: Thu, 12 Sep 2013 13:21:34 GMT
48
+ recorded_with: VCR 2.3.0
@@ -2,62 +2,17 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://graph.facebook.com/search?access_token=AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD&keyword_list=Eminem,Sting&type=adkeywordvalid
5
+ uri: https://graph.facebook.com/act_10150585630710217/reachestimate?access_token=CAAEvJ5vzhl8BAH8aCPOx0Ft9uNB147TF8weJ8hK0g7YVDRWU4eEih7tEKdJgmfk0vABZClZACJbEzyhSMbiShL6RpsfkZASfX1C9nv1AlFvjJajflqkyYZAlpE2edT0FJHjdh4NFg0ZCt0sBgq0kZABtKsjuU18aMURLE7rjKHR4X8NkXBUafg1T4uZARRNqboZD&targeting_spec=%7B%22countries%22:%5B%22US%22%5D,%22keywords%22:%5B%22Eminem%22,%22Sting%22%5D,%22age_min%22:13,%22connections%22:%5B%5D,%22broad_age%22:false%7D
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
- Accept-Encoding:
11
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
- Accept:
13
- - ! '*/*'
14
10
  User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Access-Control-Allow-Origin:
22
- - ! '*'
23
- Cache-Control:
24
- - private, no-cache, no-store, must-revalidate
25
- Content-Type:
26
- - text/javascript; charset=UTF-8
27
- Etag:
28
- - ! '"a684dbf074d5467a7775189984027b177954edef"'
29
- Expires:
30
- - Sat, 01 Jan 2000 00:00:00 GMT
31
- Pragma:
32
- - no-cache
33
- X-Fb-Rev:
34
- - '698469'
35
- X-Fb-Debug:
36
- - vtS1+m1EAAr/YCY4TKxUueU+DfmYhcASPsoK5LMzkW8=
37
- Date:
38
- - Wed, 19 Dec 2012 15:13:41 GMT
39
- Connection:
40
- - keep-alive
41
- Content-Length:
42
- - '109'
43
- body:
44
- encoding: US-ASCII
45
- string: ! '{"data":[{"name":"Eminem","valid":true,"id":6003170652434},{"name":"Sting","valid":true,"id":6003164299249}]}'
46
- http_version:
47
- recorded_at: Wed, 19 Dec 2012 15:13:42 GMT
48
- - request:
49
- method: get
50
- uri: https://graph.facebook.com/act_10150585630710217/reachestimate?access_token=AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD&targeting_spec=%7B%22countries%22:%5B%22US%22%5D,%22keywords%22:%5B%22Eminem%22,%22Sting%22%5D,%22age_min%22:13,%22connections%22:%5B%5D,%22broad_age%22:false%7D
51
- body:
52
- encoding: US-ASCII
53
- string: ''
54
- headers:
11
+ - Faraday v0.8.7
55
12
  Accept-Encoding:
56
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
14
  Accept:
58
15
  - ! '*/*'
59
- User-Agent:
60
- - Ruby
61
16
  response:
62
17
  status:
63
18
  code: 200
@@ -68,26 +23,26 @@ http_interactions:
68
23
  Cache-Control:
69
24
  - private, no-cache, no-store, must-revalidate
70
25
  Content-Type:
71
- - text/javascript; charset=UTF-8
26
+ - application/json; charset=UTF-8
72
27
  Etag:
73
- - ! '"486581ad6483292ae854bf5e25d36d1b564b1865"'
28
+ - ! '"9ac6d458b810272cafd8ce451a7f9f1f9530c83b"'
74
29
  Expires:
75
30
  - Sat, 01 Jan 2000 00:00:00 GMT
76
31
  Pragma:
77
32
  - no-cache
78
33
  X-Fb-Rev:
79
- - '698469'
34
+ - '934677'
80
35
  X-Fb-Debug:
81
- - m+Eupy9dFg5wCI+Ej1LdCnZ73lJ1YHyikHIHA1+ET5Y=
36
+ - 61VwYP47RnemHT8gXLSpsdpq6MKIPD9tWkdAbhxdaK8=
82
37
  Date:
83
- - Wed, 19 Dec 2012 15:13:43 GMT
38
+ - Thu, 12 Sep 2013 13:21:36 GMT
84
39
  Connection:
85
40
  - keep-alive
86
41
  Content-Length:
87
- - '322'
42
+ - '562'
88
43
  body:
89
44
  encoding: US-ASCII
90
- string: ! '{"users":16830580,"bid_estimations":[{"location":3,"cpc_min":43,"cpc_median":71,"cpc_max":145,"cpm_min":2,"cpm_median":15,"cpm_max":502}],"imp_estimates":[],"data":{"users":16830580,"bid_estimations":[{"location":3,"cpc_min":43,"cpc_median":71,"cpc_max":145,"cpm_min":2,"cpm_median":15,"cpm_max":502}],"imp_estimates":[]}}'
45
+ string: ! '{"users":17800000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":217,"cpa_median":391,"cpa_max":521,"cpc_min":40,"cpc_median":64,"cpc_max":85,"cpm_min":6,"cpm_median":22,"cpm_max":215}],"estimate_ready":true,"imp_estimates":[],"min_reach":null,"max_reach":null,"data":{"users":17800000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":217,"cpa_median":391,"cpa_max":521,"cpc_min":40,"cpc_median":64,"cpc_max":85,"cpm_min":6,"cpm_median":22,"cpm_max":215}],"estimate_ready":true,"imp_estimates":[],"min_reach":null,"max_reach":null}}'
91
46
  http_version:
92
- recorded_at: Wed, 19 Dec 2012 15:13:43 GMT
93
- recorded_with: VCR 2.2.4
47
+ recorded_at: Thu, 12 Sep 2013 13:21:36 GMT
48
+ recorded_with: VCR 2.3.0
@@ -2,62 +2,17 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://graph.facebook.com/search?access_token=AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD&keyword_list=Sting&type=adkeywordvalid
5
+ uri: https://graph.facebook.com/act_10150585630710217/reachestimate?access_token=CAAEvJ5vzhl8BAH8aCPOx0Ft9uNB147TF8weJ8hK0g7YVDRWU4eEih7tEKdJgmfk0vABZClZACJbEzyhSMbiShL6RpsfkZASfX1C9nv1AlFvjJajflqkyYZAlpE2edT0FJHjdh4NFg0ZCt0sBgq0kZABtKsjuU18aMURLE7rjKHR4X8NkXBUafg1T4uZARRNqboZD&targeting_spec=%7B%22countries%22:%5B%22US%22%5D,%22keywords%22:%5B%22Sting%22%5D,%22age_min%22:13,%22age_max%22:24,%22genders%22:%5B2%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
- Accept-Encoding:
11
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
- Accept:
13
- - ! '*/*'
14
10
  User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Access-Control-Allow-Origin:
22
- - ! '*'
23
- Cache-Control:
24
- - private, no-cache, no-store, must-revalidate
25
- Content-Type:
26
- - text/javascript; charset=UTF-8
27
- Etag:
28
- - ! '"66bd8a85c55324c07c1c2afcb1eac4e2fd358bf5"'
29
- Expires:
30
- - Sat, 01 Jan 2000 00:00:00 GMT
31
- Pragma:
32
- - no-cache
33
- X-Fb-Rev:
34
- - '698469'
35
- X-Fb-Debug:
36
- - XuqZnN5WjRA/b3sTn4Nz0jyvTkw2S0OCP5x8OKrUO54=
37
- Date:
38
- - Wed, 19 Dec 2012 15:20:53 GMT
39
- Connection:
40
- - keep-alive
41
- Content-Length:
42
- - '59'
43
- body:
44
- encoding: US-ASCII
45
- string: ! '{"data":[{"name":"Sting","valid":true,"id":6003164299249}]}'
46
- http_version:
47
- recorded_at: Wed, 19 Dec 2012 15:20:53 GMT
48
- - request:
49
- method: get
50
- uri: https://graph.facebook.com/act_10150585630710217/reachestimate?access_token=AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD&targeting_spec=%7B%22countries%22:%5B%22US%22%5D,%22keywords%22:%5B%22Sting%22%5D,%22age_min%22:13,%22age_max%22:24,%22genders%22:%5B2%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
51
- body:
52
- encoding: US-ASCII
53
- string: ''
54
- headers:
11
+ - Faraday v0.8.7
55
12
  Accept-Encoding:
56
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
57
14
  Accept:
58
15
  - ! '*/*'
59
- User-Agent:
60
- - Ruby
61
16
  response:
62
17
  status:
63
18
  code: 200
@@ -68,26 +23,26 @@ http_interactions:
68
23
  Cache-Control:
69
24
  - private, no-cache, no-store, must-revalidate
70
25
  Content-Type:
71
- - text/javascript; charset=UTF-8
26
+ - application/json; charset=UTF-8
72
27
  Etag:
73
- - ! '"430ebe9f4489fdfc008a2c301d51e68d633c8978"'
28
+ - ! '"ed45c65e395f6b7bcfd3dcbb4451e915b2ab464d"'
74
29
  Expires:
75
30
  - Sat, 01 Jan 2000 00:00:00 GMT
76
31
  Pragma:
77
32
  - no-cache
78
33
  X-Fb-Rev:
79
- - '698469'
34
+ - '934677'
80
35
  X-Fb-Debug:
81
- - H+RabGZXmTXmsUVynJuDJRCthPTjpJLfPD7iwdJA3WA=
36
+ - MFmGzAEJviAufFQtZWEOYbuCwzuNMsFYRc+LXv34UT8=
82
37
  Date:
83
- - Wed, 19 Dec 2012 15:20:55 GMT
38
+ - Thu, 12 Sep 2013 13:21:38 GMT
84
39
  Connection:
85
40
  - keep-alive
86
41
  Content-Length:
87
- - '314'
42
+ - '552'
88
43
  body:
89
44
  encoding: US-ASCII
90
- string: ! '{"users":39400,"bid_estimations":[{"location":3,"cpc_min":38,"cpc_median":58,"cpc_max":115,"cpm_min":1,"cpm_median":6,"cpm_max":383}],"imp_estimates":[],"data":{"users":39400,"bid_estimations":[{"location":3,"cpc_min":38,"cpc_median":58,"cpc_max":115,"cpm_min":1,"cpm_median":6,"cpm_max":383}],"imp_estimates":[]}}'
45
+ string: ! '{"users":38000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":246,"cpa_median":424,"cpa_max":578,"cpc_min":37,"cpc_median":59,"cpc_max":76,"cpm_min":3,"cpm_median":8,"cpm_max":15}],"estimate_ready":true,"imp_estimates":[],"min_reach":null,"max_reach":null,"data":{"users":38000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":246,"cpa_median":424,"cpa_max":578,"cpc_min":37,"cpc_median":59,"cpc_max":76,"cpm_min":3,"cpm_median":8,"cpm_max":15}],"estimate_ready":true,"imp_estimates":[],"min_reach":null,"max_reach":null}}'
91
46
  http_version:
92
- recorded_at: Wed, 19 Dec 2012 15:20:55 GMT
93
- recorded_with: VCR 2.2.4
47
+ recorded_at: Thu, 12 Sep 2013 13:21:38 GMT
48
+ recorded_with: VCR 2.3.0
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Zuck::AdKeyword do
4
- let(:graph){ Koala::Facebook::API.new('CAAEvJ5vzhl8BAE7m0kztNbbASKHymRlXoBZCdZCtMsebNEgaR0yOmZCBfeTIXT8MnuV3ZCH5lBDQOcC4S9geswWZBuF707gJ42lV9DHgGILsRaiG2upipiHggl7UZAeDVgBSSsap9s9uv1ghZCxNsmH')}
4
+ let(:graph){ Koala::Facebook::API.new(test_access_token)}
5
5
 
6
6
  it "finds the best keyword with a #" do
7
7
  VCR.use_cassette('ad_keyword_search_disney') do
@@ -10,8 +10,8 @@ describe Zuck::AdKeyword do
10
10
  end
11
11
 
12
12
  it "finds the best keyword when no keyword with # is available" do
13
- VCR.use_cassette('ad_keyword_search_steve_carell') do
14
- Zuck::AdKeyword.best_guess(graph, 'steve carell')[:keyword].should == 'Steve Carell'
13
+ VCR.use_cassette('ad_keyword_search_moviepilot') do
14
+ Zuck::AdKeyword.best_guess(graph, 'moviepilot')[:keyword].should == 'Moviepilot'
15
15
  end
16
16
  end
17
17
 
@@ -87,7 +87,7 @@ describe Zuck::TargetingSpec do
87
87
  end
88
88
 
89
89
  describe "fetching reach" do
90
- let(:graph){ Koala::Facebook::API.new('AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD') }
90
+ let(:graph){ Koala::Facebook::API.new(test_access_token) }
91
91
  let(:ad_account){ 'act_10150585630710217' }
92
92
 
93
93
  it "bugs out when trying to use an invalid keyword" do
@@ -105,7 +105,7 @@ describe Zuck::TargetingSpec do
105
105
  spec = {countries: ['us'], keywords: ['Eminem', 'Sting'] }
106
106
  ts = Zuck::TargetingSpec.new(graph, ad_account, spec)
107
107
  reach = ts.fetch_reach
108
- reach[:users].should == 16830580
108
+ reach[:users].should == 17800000
109
109
  end
110
110
  end
111
111
 
@@ -114,7 +114,7 @@ describe Zuck::TargetingSpec do
114
114
  spec = {countries: ['us'], keywords: ['Sting'], gender: :female, age_class: :young }
115
115
  ts = Zuck::TargetingSpec.new(graph, ad_account, spec)
116
116
  reach = ts.fetch_reach
117
- reach[:users].should == 39400
117
+ reach[:users].should == 38000
118
118
  end
119
119
  end
120
120
 
@@ -129,7 +129,7 @@ describe Zuck::TargetingSpec do
129
129
  end
130
130
 
131
131
  describe "Batch processing" do
132
- let(:graph){ Koala::Facebook::API.new('AAAEvJ5vzhl8BAPLr6fQgNy2wdUHDJ7ZAoX9PTZCFnebwuTBZBEqO7lNTVZA3XNsTHPTATpTmVFs6o6Jp1pZAL8ZA54BRBXWYtztVug8bm2BAZDZD') }
132
+ let(:graph){ Koala::Facebook::API.new(test_access_token) }
133
133
  let(:ad_account){ 'act_10150585630710217' }
134
134
  let(:spec_mock){ mock(fetch_reach: {some: :data}) }
135
135
 
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  class HTest
4
4
  extend Zuck::FbObject::Helpers
5
5
  include Zuck::FbObject::Helpers
6
+ def self.known_keys; []; end
6
7
  end
7
8
 
8
9
  describe Zuck::FbObject::Helpers do
@@ -11,12 +12,12 @@ describe Zuck::FbObject::Helpers do
11
12
 
12
13
  context "get" do
13
14
  it "forwards to koala" do
14
- graph_mock.should_receive(:get_object).with('/foo').and_return(true)
15
+ graph_mock.should_receive(:get_object).with('/foo', fields: '').and_return(true)
15
16
  HTest.send(:get, graph_mock, "/foo")
16
17
  end
17
18
 
18
19
  it "does not swallow exceptions" do
19
- graph_mock.should_receive(:get_object).with('/foo').and_raise("broken")
20
+ graph_mock.should_receive(:get_object).with('/foo', fields: '').and_raise("broken")
20
21
  expect{
21
22
  HTest.send(:get, graph_mock, "/foo")
22
23
  }.to raise_error("broken")
@@ -3,14 +3,14 @@ require 'spec_helper'
3
3
  describe Zuck::FbObject do
4
4
 
5
5
  before(:all) do
6
- Zuck.graph = Koala::Facebook::API.new('AAAEvJ5vzhl8BABhTSazJZB2D0B4N0l242VX22Hg9J2WZA7fptcAztfXxfAZB9mhZB6W1nl5dz5tXMlb9DJk9ibs6RqtP7PtO6a3XCiHWVwZDZD')
6
+ Zuck.graph = Koala::Facebook::API.new(test_access_token)
7
7
  end
8
8
 
9
9
  let(:graph) { Zuck.graph }
10
10
  let(:account) { Zuck::AdAccount.new(graph, {id: "act_10150585630710217"}) }
11
- let(:campaign){ Zuck::AdCampaign.new(graph, {id: "6005950787751"}, account) }
12
- let(:group) { Zuck::AdGroup.new(graph, {id: "6004497038951"}, campaign)}
13
- let(:creative){ Zuck::AdCreative.new(graph, {id: "1234567890123"}, group) }
11
+ let(:campaign){ Zuck::AdCampaign.new(graph, {id: "6010889111951"}, account) }
12
+ let(:group) { Zuck::AdGroup.new(graph, {id: "6010889169151"}, campaign)}
13
+ let(:creative){ Zuck::AdCreative.new(graph, {id: "6010888561951"}, group) }
14
14
 
15
15
 
16
16
  describe "read only objects" do
@@ -44,13 +44,13 @@ describe Zuck::FbObject do
44
44
 
45
45
  it "a list of ad campaigns" do
46
46
  VCR.use_cassette('list_of_ad_campaigns') do
47
- account.ad_campaigns.should have(3).items
47
+ account.ad_campaigns.should have(8).items
48
48
  end
49
49
  end
50
50
 
51
51
  it "a list of ad groups" do
52
52
  VCR.use_cassette('list_of_ad_groups') do
53
- campaign.ad_groups.should have(1).item
53
+ campaign.ad_groups.should have(9).item
54
54
  end
55
55
  end
56
56
 
@@ -64,43 +64,35 @@ describe Zuck::FbObject do
64
64
  g = graph
65
65
  Zuck::AdAccount.should_receive(:all).and_return([account])
66
66
  VCR.use_cassette('list_of_all_ad_creatives_of_account') do
67
- Zuck::AdCreative.all(g).should have(6).items
67
+ Zuck::AdCreative.all(g).should have(9).items
68
68
  end
69
69
  end
70
70
 
71
71
  context "an id directly" do
72
72
 
73
- it "with the correct type" do
73
+ it "campaign with the correct type" do
74
74
  VCR.use_cassette('a_single_campaign') do
75
75
  c = Zuck::AdCampaign.find(6005950787751, graph)
76
76
  end
77
77
  end
78
78
 
79
- it "with the correct type" do
79
+ it "account with the correct type" do
80
80
  VCR.use_cassette('a_single_account') do
81
81
  c = Zuck::AdAccount.find('act_10150585630710217', graph)
82
82
  end
83
83
  end
84
84
 
85
85
  it "when expecting an ad group but the id belongs to a campaign" do
86
- expected_error = <<-END_ERROR
87
- Invalid type.
88
-
89
- Expected data['id']="6005950787751" to be equal to one of these:
90
- * data['account_id']="10150585630710217"
91
- * data['group_id']=nil
92
- * data['adgroup_id']=nil
93
- END_ERROR
94
- VCR.use_cassette('a_single_campaign') do
86
+ VCR.use_cassette('a_single_group') do
95
87
  expect{
96
- c = Zuck::AdGroup.find(6005950787751, graph)
97
- }.to raise_error(expected_error)
88
+ c = Zuck::AdGroup.find(6010889111951, graph)
89
+ }.to raise_error(Koala::Facebook::ClientError)
98
90
  end
99
91
  end
100
92
 
101
93
  it "and saving it" do
102
- VCR.use_cassette('find_a_single_campaign_and_update_it') do
103
- group = Zuck::AdGroup.find(6005859287551, graph)
94
+ VCR.use_cassette('find_a_single_group_and_update_it') do
95
+ group = Zuck::AdGroup.find(6010889169151, graph)
104
96
  group.name = "My old name"
105
97
  group.save
106
98
  group.name.should == "My old name"
@@ -135,7 +127,7 @@ END_ERROR
135
127
 
136
128
  it "an ad group" do
137
129
  VCR.use_cassette('create_ad_group') do
138
- o = {bid_type: 1, max_bid: 1, name: "Rap like me", targeting: '{"countries":["US"]}',
130
+ o = {bid_type: 'CPC', max_bid: 1, name: "Rap like me", targeting: '{"countries":["US"]}',
139
131
  creative: '{"type":25,"action_spec":{"action.type":"like", "post":10150420410887685}}'}
140
132
  group = Zuck::AdGroup.create(graph, o, campaign)
141
133
  group.name.should == "Rap like me"
@@ -144,10 +136,11 @@ END_ERROR
144
136
 
145
137
  it "an ad group via an existing ad campaign" do
146
138
  VCR.use_cassette('create_ad_group') do
147
- o = {bid_type: 1, max_bid: 1, name: "Rap like me", targeting: '{"countries":["US"]}',
139
+ o = {bid_type: 'CPC', max_bid: 1, name: "Rap like me", targeting: '{"countries":["US"]}',
148
140
  creative: '{"type":25,"action_spec":{"action.type":"like", "post":10150420410887685}}'}
149
141
  group = campaign.create_ad_group(o)
150
142
  group.name.should == "Rap like me"
143
+ # Until Oct 2013 Facebook will return the magic ints, and then the enums
151
144
  group.bid_type.should == 1
152
145
  end
153
146
  end