yt 0.22.1 → 0.22.2

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.
@@ -56,6 +56,40 @@ describe Yt::Playlist, :partner do
56
56
  end
57
57
  end
58
58
 
59
+ describe 'views can be retrieved for a single US state' do
60
+ let(:state_code) { 'CA' }
61
+ let(:result) { playlist.views since: date, by: by, in: location }
62
+ let(:date) { 4.days.ago }
63
+
64
+ context 'and grouped by day' do
65
+ let(:by) { :day }
66
+
67
+ context 'with the :in option set to {state: state code}' do
68
+ let(:location) { {state: state_code} }
69
+ it { expect(result.keys.min).to eq date.to_date }
70
+ end
71
+
72
+ context 'with the :in option set to {country: "US", state: state code}' do
73
+ let(:location) { {country: 'US', state: state_code} }
74
+ it { expect(result.keys.min).to eq date.to_date }
75
+ end
76
+ end
77
+
78
+ context 'and grouped by US state' do
79
+ let(:by) { :state }
80
+
81
+ context 'with the :in option set to {state: state code}' do
82
+ let(:location) { {state: state_code} }
83
+ it { expect(result.keys).to eq [state_code] }
84
+ end
85
+
86
+ context 'with the :in option set to {country: "US", state: state code}' do
87
+ let(:location) { {country: 'US', state: state_code} }
88
+ it { expect(result.keys).to eq [state_code] }
89
+ end
90
+ end
91
+ end
92
+
59
93
  describe 'views can be retrieved for a range of days' do
60
94
  let(:date) { 4.days.ago }
61
95
 
@@ -130,6 +164,15 @@ describe Yt::Playlist, :partner do
130
164
  end
131
165
  end
132
166
 
167
+ describe 'views can be grouped by search term' do
168
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
169
+
170
+ specify 'with the :by option set to :search_term' do
171
+ views = playlist.views range.merge by: :search_term
172
+ expect(views.keys).to all(be_a String)
173
+ end
174
+ end
175
+
133
176
  describe 'views can be grouped by video' do
134
177
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
135
178
 
@@ -170,7 +213,7 @@ describe Yt::Playlist, :partner do
170
213
  end
171
214
 
172
215
  describe 'views can be grouped by state' do
173
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
216
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
174
217
 
175
218
  specify 'with the :by option set to :state' do
176
219
  views = playlist.views range.merge by: :state
@@ -226,6 +269,40 @@ describe Yt::Playlist, :partner do
226
269
  end
227
270
  end
228
271
 
272
+ describe 'estimated minutes watched can be retrieved for a single US state' do
273
+ let(:state_code) { 'CA' }
274
+ let(:result) { playlist.estimated_minutes_watched since: date, by: by, in: location }
275
+ let(:date) { 4.days.ago }
276
+
277
+ context 'and grouped by day' do
278
+ let(:by) { :day }
279
+
280
+ context 'with the :in option set to {state: state code}' do
281
+ let(:location) { {state: state_code} }
282
+ it { expect(result.keys.min).to eq date.to_date }
283
+ end
284
+
285
+ context 'with the :in option set to {country: "US", state: state code}' do
286
+ let(:location) { {country: 'US', state: state_code} }
287
+ it { expect(result.keys.min).to eq date.to_date }
288
+ end
289
+ end
290
+
291
+ context 'and grouped by US state' do
292
+ let(:by) { :state }
293
+
294
+ context 'with the :in option set to {state: state code}' do
295
+ let(:location) { {state: state_code} }
296
+ it { expect(result.keys).to eq [state_code] }
297
+ end
298
+
299
+ context 'with the :in option set to {country: "US", state: state code}' do
300
+ let(:location) { {country: 'US', state: state_code} }
301
+ it { expect(result.keys).to eq [state_code] }
302
+ end
303
+ end
304
+ end
305
+
229
306
  describe 'estimated minutes watched can be retrieved for a range of days' do
230
307
  let(:date) { 4.days.ago }
231
308
 
@@ -300,6 +377,15 @@ describe Yt::Playlist, :partner do
300
377
  end
301
378
  end
302
379
 
380
+ describe 'estimated minutes watched can be grouped by search term' do
381
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
382
+
383
+ specify 'with the :by option set to :search_term' do
384
+ minutes = playlist.estimated_minutes_watched range.merge by: :search_term
385
+ expect(minutes.keys).to all(be_a String)
386
+ end
387
+ end
388
+
303
389
  describe 'estimated minutes watched can be grouped by video' do
304
390
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
305
391
 
@@ -340,7 +426,7 @@ describe Yt::Playlist, :partner do
340
426
  end
341
427
 
342
428
  describe 'estimated minutes watched can be grouped by state' do
343
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
429
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
344
430
 
345
431
  specify 'with the :by option set to :state' do
346
432
  minutes = playlist.estimated_minutes_watched range.merge by: :state
@@ -447,6 +533,40 @@ describe Yt::Playlist, :partner do
447
533
  end
448
534
  end
449
535
 
536
+ describe 'average view duration can be retrieved for a single US state' do
537
+ let(:state_code) { 'CA' }
538
+ let(:result) { playlist.average_view_duration since: date, by: by, in: location }
539
+ let(:date) { 4.days.ago }
540
+
541
+ context 'and grouped by day' do
542
+ let(:by) { :day }
543
+
544
+ context 'with the :in option set to {state: state code}' do
545
+ let(:location) { {state: state_code} }
546
+ it { expect(result.keys.min).to eq date.to_date }
547
+ end
548
+
549
+ context 'with the :in option set to {country: "US", state: state code}' do
550
+ let(:location) { {country: 'US', state: state_code} }
551
+ it { expect(result.keys.min).to eq date.to_date }
552
+ end
553
+ end
554
+
555
+ context 'and grouped by US state' do
556
+ let(:by) { :state }
557
+
558
+ context 'with the :in option set to {state: state code}' do
559
+ let(:location) { {state: state_code} }
560
+ it { expect(result.keys).to eq [state_code] }
561
+ end
562
+
563
+ context 'with the :in option set to {country: "US", state: state code}' do
564
+ let(:location) { {country: 'US', state: state_code} }
565
+ it { expect(result.keys).to eq [state_code] }
566
+ end
567
+ end
568
+ end
569
+
450
570
  describe 'average view duration can be retrieved for a range of days' do
451
571
  let(:date) { 4.days.ago }
452
572
 
@@ -504,7 +624,7 @@ describe Yt::Playlist, :partner do
504
624
  end
505
625
 
506
626
  describe 'average view duration can be grouped by state' do
507
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
627
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
508
628
 
509
629
  specify 'with the :by option set to :state' do
510
630
  duration = playlist.average_view_duration range.merge by: :state
@@ -560,6 +680,40 @@ describe Yt::Playlist, :partner do
560
680
  end
561
681
  end
562
682
 
683
+ describe 'playlist starts can be retrieved for a single US state' do
684
+ let(:state_code) { 'CA' }
685
+ let(:result) { playlist.playlist_starts since: date, by: by, in: location }
686
+ let(:date) { 4.days.ago }
687
+
688
+ context 'and grouped by day' do
689
+ let(:by) { :day }
690
+
691
+ context 'with the :in option set to {state: state code}' do
692
+ let(:location) { {state: state_code} }
693
+ it { expect(result.keys.min).to eq date.to_date }
694
+ end
695
+
696
+ context 'with the :in option set to {country: "US", state: state code}' do
697
+ let(:location) { {country: 'US', state: state_code} }
698
+ it { expect(result.keys.min).to eq date.to_date }
699
+ end
700
+ end
701
+
702
+ context 'and grouped by US state' do
703
+ let(:by) { :state }
704
+
705
+ context 'with the :in option set to {state: state code}' do
706
+ let(:location) { {state: state_code} }
707
+ it { expect(result.keys).to eq [state_code] }
708
+ end
709
+
710
+ context 'with the :in option set to {country: "US", state: state code}' do
711
+ let(:location) { {country: 'US', state: state_code} }
712
+ it { expect(result.keys).to eq [state_code] }
713
+ end
714
+ end
715
+ end
716
+
563
717
  describe 'playlist starts can be retrieved for a range of days' do
564
718
  let(:date) { 4.days.ago }
565
719
 
@@ -617,7 +771,7 @@ describe Yt::Playlist, :partner do
617
771
  end
618
772
 
619
773
  describe 'playlist starts can be grouped by state' do
620
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
774
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
621
775
 
622
776
  specify 'with the :by option set to :state' do
623
777
  starts = playlist.playlist_starts range.merge by: :state
@@ -673,6 +827,40 @@ describe Yt::Playlist, :partner do
673
827
  end
674
828
  end
675
829
 
830
+ describe 'average time in playlist can be retrieved for a single US state' do
831
+ let(:state_code) { 'CA' }
832
+ let(:result) { playlist.average_time_in_playlist since: date, by: by, in: location }
833
+ let(:date) { 4.days.ago }
834
+
835
+ context 'and grouped by day' do
836
+ let(:by) { :day }
837
+
838
+ context 'with the :in option set to {state: state code}' do
839
+ let(:location) { {state: state_code} }
840
+ it { expect(result.keys.min).to eq date.to_date }
841
+ end
842
+
843
+ context 'with the :in option set to {country: "US", state: state code}' do
844
+ let(:location) { {country: 'US', state: state_code} }
845
+ it { expect(result.keys.min).to eq date.to_date }
846
+ end
847
+ end
848
+
849
+ context 'and grouped by US state' do
850
+ let(:by) { :state }
851
+
852
+ context 'with the :in option set to {state: state code}' do
853
+ let(:location) { {state: state_code} }
854
+ it { expect(result.keys).to eq [state_code] }
855
+ end
856
+
857
+ context 'with the :in option set to {country: "US", state: state code}' do
858
+ let(:location) { {country: 'US', state: state_code} }
859
+ it { expect(result.keys).to eq [state_code] }
860
+ end
861
+ end
862
+ end
863
+
676
864
  describe 'average time in playlist can be retrieved for a range of days' do
677
865
  let(:date) { 4.days.ago }
678
866
 
@@ -730,7 +918,7 @@ describe Yt::Playlist, :partner do
730
918
  end
731
919
 
732
920
  describe 'average time in playlist can be grouped by state' do
733
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
921
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
734
922
 
735
923
  specify 'with the :by option set to :state' do
736
924
  time = playlist.average_time_in_playlist range.merge by: :state
@@ -786,6 +974,40 @@ describe Yt::Playlist, :partner do
786
974
  end
787
975
  end
788
976
 
977
+ describe 'views per playlists start can be retrieved for a single US state' do
978
+ let(:state_code) { 'CA' }
979
+ let(:result) { playlist.views_per_playlist_start since: date, by: by, in: location }
980
+ let(:date) { 4.days.ago }
981
+
982
+ context 'and grouped by day' do
983
+ let(:by) { :day }
984
+
985
+ context 'with the :in option set to {state: state code}' do
986
+ let(:location) { {state: state_code} }
987
+ it { expect(result.keys.min).to eq date.to_date }
988
+ end
989
+
990
+ context 'with the :in option set to {country: "US", state: state code}' do
991
+ let(:location) { {country: 'US', state: state_code} }
992
+ it { expect(result.keys.min).to eq date.to_date }
993
+ end
994
+ end
995
+
996
+ context 'and grouped by US state' do
997
+ let(:by) { :state }
998
+
999
+ context 'with the :in option set to {state: state code}' do
1000
+ let(:location) { {state: state_code} }
1001
+ it { expect(result.keys).to eq [state_code] }
1002
+ end
1003
+
1004
+ context 'with the :in option set to {country: "US", state: state code}' do
1005
+ let(:location) { {country: 'US', state: state_code} }
1006
+ it { expect(result.keys).to eq [state_code] }
1007
+ end
1008
+ end
1009
+ end
1010
+
789
1011
  describe 'views per playlist start can be retrieved for a range of days' do
790
1012
  let(:date) { 4.days.ago }
791
1013
 
@@ -843,7 +1065,7 @@ describe Yt::Playlist, :partner do
843
1065
  end
844
1066
 
845
1067
  describe 'views per playlist start can be grouped by state' do
846
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
1068
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
847
1069
 
848
1070
  specify 'with the :by option set to :state' do
849
1071
  views = playlist.views_per_playlist_start range.merge by: :state
@@ -120,7 +120,6 @@ describe Yt::Video, :partner do
120
120
  end
121
121
  end
122
122
 
123
-
124
123
  describe 'views can be retrieved for a single country' do
125
124
  let(:country_code) { 'US' }
126
125
  let(:views) { video.views since: date, by: by, in: location }
@@ -153,6 +152,54 @@ describe Yt::Video, :partner do
153
152
  it { expect(views.keys).to eq [country_code] }
154
153
  end
155
154
  end
155
+
156
+ context 'and grouped by state' do
157
+ let(:by) { :state }
158
+
159
+ context 'with the :in option set to the country code' do
160
+ let(:location) { country_code }
161
+ it { expect(views.keys.map(&:length).uniq).to eq [2] }
162
+ end
163
+
164
+ context 'with the :in option set to {country: country code}' do
165
+ let(:location) { {country: country_code} }
166
+ it { expect(views.keys.map(&:length).uniq).to eq [2] }
167
+ end
168
+ end
169
+ end
170
+
171
+ describe 'views can be retrieved for a single US state' do
172
+ let(:state_code) { 'NY' }
173
+ let(:views) { video.views since: date, by: by, in: location }
174
+ let(:date) { 4.days.ago }
175
+
176
+ context 'and grouped by day' do
177
+ let(:by) { :day }
178
+
179
+ context 'with the :in option set to {state: state code}' do
180
+ let(:location) { {state: state_code} }
181
+ it { expect(views.keys.min).to eq date.to_date }
182
+ end
183
+
184
+ context 'with the :in option set to {country: "US", state: state code}' do
185
+ let(:location) { {country: 'US', state: state_code} }
186
+ it { expect(views.keys.min).to eq date.to_date }
187
+ end
188
+ end
189
+
190
+ context 'and grouped by US state' do
191
+ let(:by) { :state }
192
+
193
+ context 'with the :in option set to {state: state code}' do
194
+ let(:location) { {state: state_code} }
195
+ it { expect(views.keys).to eq [state_code] }
196
+ end
197
+
198
+ context 'with the :in option set to {country: "US", state: state code}' do
199
+ let(:location) { {country: 'US', state: state_code} }
200
+ it { expect(views.keys).to eq [state_code] }
201
+ end
202
+ end
156
203
  end
157
204
 
158
205
  describe 'views can be retrieved for a range of days' do
@@ -238,6 +285,15 @@ describe Yt::Video, :partner do
238
285
  end
239
286
  end
240
287
 
288
+ describe 'views can be grouped by search term' do
289
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
290
+
291
+ specify 'with the :by option set to :search_term' do
292
+ views = video.views range.merge by: :search_term
293
+ expect(views.keys).to all(be_a String)
294
+ end
295
+ end
296
+
241
297
  describe 'views can be grouped by device type' do
242
298
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
243
299
 
@@ -270,6 +326,81 @@ describe Yt::Video, :partner do
270
326
  end
271
327
  end
272
328
 
329
+ describe 'uniques can be retrieved for a single country' do
330
+ let(:country_code) { 'US' }
331
+ let(:uniques) { video.uniques since: date, by: by, in: location }
332
+ let(:date) { 4.days.ago }
333
+
334
+ context 'and grouped by day' do
335
+ let(:by) { :day }
336
+
337
+ context 'with the :in option set to the country code' do
338
+ let(:location) { country_code }
339
+ it { expect(uniques.keys.min).to eq date.to_date }
340
+ end
341
+
342
+ context 'with the :in option set to {country: country code}' do
343
+ let(:location) { {country: country_code} }
344
+ it { expect(uniques.keys.min).to eq date.to_date }
345
+ end
346
+ end
347
+ end
348
+
349
+ describe 'uniques can be retrieved for a single US state' do
350
+ let(:state_code) { 'NY' }
351
+ let(:result) { video.uniques since: date, by: by, in: location }
352
+ let(:date) { 4.days.ago }
353
+
354
+ context 'and grouped by day' do
355
+ let(:by) { :day }
356
+
357
+ context 'with the :in option set to {state: state code}' do
358
+ let(:location) { {state: state_code} }
359
+ it { expect(result.keys.min).to eq date.to_date }
360
+ end
361
+
362
+ context 'with the :in option set to {country: "US", state: state code}' do
363
+ let(:location) { {country: 'US', state: state_code} }
364
+ it { expect(result.keys.min).to eq date.to_date }
365
+ end
366
+ end
367
+ end
368
+
369
+ describe 'uniques can be retrieved for a range of days' do
370
+ let(:date) { 4.days.ago }
371
+
372
+ specify 'with a given start (:since option)' do
373
+ expect(video.uniques(since: date).keys.min).to eq date.to_date
374
+ end
375
+
376
+ specify 'with a given end (:until option)' do
377
+ expect(video.uniques(until: date).keys.max).to eq date.to_date
378
+ end
379
+
380
+ specify 'with a given start (:from option)' do
381
+ expect(video.uniques(from: date).keys.min).to eq date.to_date
382
+ end
383
+
384
+ specify 'with a given end (:to option)' do
385
+ expect(video.uniques(to: date).keys.max).to eq date.to_date
386
+ end
387
+ end
388
+
389
+ describe 'uniques can be grouped by day' do
390
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
391
+ let(:keys) { range.values }
392
+
393
+ specify 'without a :by option (default)' do
394
+ uniques = video.uniques range
395
+ expect(uniques.keys).to eq range.values
396
+ end
397
+
398
+ specify 'with the :by option set to :day' do
399
+ uniques = video.uniques range.merge by: :day
400
+ expect(uniques.keys).to eq range.values
401
+ end
402
+ end
403
+
273
404
  describe 'comments can be retrieved for a specific day' do
274
405
  context 'in which the video was partnered' do
275
406
  let(:comments) { video.comments_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
@@ -1137,6 +1268,40 @@ describe Yt::Video, :partner do
1137
1268
  end
1138
1269
  end
1139
1270
 
1271
+ describe 'estimated minutes watched can be retrieved for a single US state' do
1272
+ let(:state_code) { 'NY' }
1273
+ let(:minutes) { video.estimated_minutes_watched since: date, by: by, in: location }
1274
+ let(:date) { 4.days.ago }
1275
+
1276
+ context 'and grouped by day' do
1277
+ let(:by) { :day }
1278
+
1279
+ context 'with the :in option set to {state: state code}' do
1280
+ let(:location) { {state: state_code} }
1281
+ it { expect(minutes.keys.min).to eq date.to_date }
1282
+ end
1283
+
1284
+ context 'with the :in option set to {country: "US", state: state code}' do
1285
+ let(:location) { {country: 'US', state: state_code} }
1286
+ it { expect(minutes.keys.min).to eq date.to_date }
1287
+ end
1288
+ end
1289
+
1290
+ context 'and grouped by US state' do
1291
+ let(:by) { :state }
1292
+
1293
+ context 'with the :in option set to {state: state code}' do
1294
+ let(:location) { {state: state_code} }
1295
+ it { expect(minutes.keys).to eq [state_code] }
1296
+ end
1297
+
1298
+ context 'with the :in option set to {country: "US", state: state code}' do
1299
+ let(:location) { {country: 'US', state: state_code} }
1300
+ it { expect(minutes.keys).to eq [state_code] }
1301
+ end
1302
+ end
1303
+ end
1304
+
1140
1305
  describe 'estimated minutes watched can be retrieved for a range of days' do
1141
1306
  let(:date) { 4.days.ago }
1142
1307
 
@@ -1220,6 +1385,15 @@ describe Yt::Video, :partner do
1220
1385
  end
1221
1386
  end
1222
1387
 
1388
+ describe 'estimated minutes watched can be grouped by search term' do
1389
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
1390
+
1391
+ specify 'with the :by option set to :search_term' do
1392
+ estimated_minutes_watched = video.estimated_minutes_watched range.merge by: :search_term
1393
+ expect(estimated_minutes_watched.keys).to all(be_a String)
1394
+ end
1395
+ end
1396
+
1223
1397
  describe 'estimated minutes watched can be grouped by device type' do
1224
1398
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
1225
1399
 
@@ -1298,6 +1472,40 @@ describe Yt::Video, :partner do
1298
1472
  end
1299
1473
  end
1300
1474
 
1475
+ describe 'average view duration can be retrieved for a single US state' do
1476
+ let(:state_code) { 'NY' }
1477
+ let(:duration) { video.average_view_duration since: date, by: by, in: location }
1478
+ let(:date) { 4.days.ago }
1479
+
1480
+ context 'and grouped by day' do
1481
+ let(:by) { :day }
1482
+
1483
+ context 'with the :in option set to {state: state code}' do
1484
+ let(:location) { {state: state_code} }
1485
+ it { expect(duration.keys.min).to eq date.to_date }
1486
+ end
1487
+
1488
+ context 'with the :in option set to {country: "US", state: state code}' do
1489
+ let(:location) { {country: 'US', state: state_code} }
1490
+ it { expect(duration.keys.min).to eq date.to_date }
1491
+ end
1492
+ end
1493
+
1494
+ context 'and grouped by US state' do
1495
+ let(:by) { :state }
1496
+
1497
+ context 'with the :in option set to {state: state code}' do
1498
+ let(:location) { {state: state_code} }
1499
+ it { expect(duration.keys).to eq [state_code] }
1500
+ end
1501
+
1502
+ context 'with the :in option set to {country: "US", state: state code}' do
1503
+ let(:location) { {country: 'US', state: state_code} }
1504
+ it { expect(duration.keys).to eq [state_code] }
1505
+ end
1506
+ end
1507
+ end
1508
+
1301
1509
  describe 'average view duration can be retrieved for a range of days' do
1302
1510
  let(:date) { 4.days.ago }
1303
1511
 
@@ -1411,6 +1619,40 @@ describe Yt::Video, :partner do
1411
1619
  end
1412
1620
  end
1413
1621
 
1622
+ describe 'average view percentage can be retrieved for a single US state' do
1623
+ let(:state_code) { 'NY' }
1624
+ let(:percentage) { video.average_view_percentage since: date, by: by, in: location }
1625
+ let(:date) { 4.days.ago }
1626
+
1627
+ context 'and grouped by day' do
1628
+ let(:by) { :day }
1629
+
1630
+ context 'with the :in option set to {state: state code}' do
1631
+ let(:location) { {state: state_code} }
1632
+ it { expect(percentage.keys.min).to eq date.to_date }
1633
+ end
1634
+
1635
+ context 'with the :in option set to {country: "US", state: state code}' do
1636
+ let(:location) { {country: 'US', state: state_code} }
1637
+ it { expect(percentage.keys.min).to eq date.to_date }
1638
+ end
1639
+ end
1640
+
1641
+ context 'and grouped by US state' do
1642
+ let(:by) { :state }
1643
+
1644
+ context 'with the :in option set to {state: state code}' do
1645
+ let(:location) { {state: state_code} }
1646
+ it { expect(percentage.keys).to eq [state_code] }
1647
+ end
1648
+
1649
+ context 'with the :in option set to {country: "US", state: state code}' do
1650
+ let(:location) { {country: 'US', state: state_code} }
1651
+ it { expect(percentage.keys).to eq [state_code] }
1652
+ end
1653
+ end
1654
+ end
1655
+
1414
1656
  describe 'average view percentage can be retrieved for a range of days' do
1415
1657
  let(:date) { 4.days.ago }
1416
1658
 
@@ -1695,6 +1937,88 @@ describe Yt::Video, :partner do
1695
1937
  end
1696
1938
  end
1697
1939
 
1940
+ describe 'annotation clicks can be retrieved for a single country' do
1941
+ let(:country_code) { 'US' }
1942
+ let(:annotation_clicks) { video.annotation_clicks since: date, by: by, in: location }
1943
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1944
+
1945
+ context 'and grouped by day' do
1946
+ let(:by) { :day }
1947
+
1948
+ context 'with the :in option set to the country code' do
1949
+ let(:location) { country_code }
1950
+ it { expect(annotation_clicks.keys.min).to eq date.to_date }
1951
+ end
1952
+
1953
+ context 'with the :in option set to {country: country code}' do
1954
+ let(:location) { {country: country_code} }
1955
+ it { expect(annotation_clicks.keys.min).to eq date.to_date }
1956
+ end
1957
+ end
1958
+
1959
+ context 'and grouped by country' do
1960
+ let(:by) { :country }
1961
+
1962
+ context 'with the :in option set to the country code' do
1963
+ let(:location) { country_code }
1964
+ it { expect(annotation_clicks.keys).to eq [country_code] }
1965
+ end
1966
+
1967
+ context 'with the :in option set to {country: country code}' do
1968
+ let(:location) { {country: country_code} }
1969
+ it { expect(annotation_clicks.keys).to eq [country_code] }
1970
+ end
1971
+ end
1972
+
1973
+ context 'and grouped by state' do
1974
+ let(:by) { :state }
1975
+
1976
+ context 'with the :in option set to the country code' do
1977
+ let(:location) { country_code }
1978
+ it { expect(annotation_clicks.keys.map(&:length).uniq).to eq [2] }
1979
+ end
1980
+
1981
+ context 'with the :in option set to {country: country code}' do
1982
+ let(:location) { {country: country_code} }
1983
+ it { expect(annotation_clicks.keys.map(&:length).uniq).to eq [2] }
1984
+ end
1985
+ end
1986
+ end
1987
+
1988
+ describe 'annotation clicks can be retrieved for a single US state' do
1989
+ let(:state_code) { 'CA' }
1990
+ let(:clicks) { video.annotation_clicks since: date, by: by, in: location }
1991
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1992
+
1993
+ context 'and grouped by day' do
1994
+ let(:by) { :day }
1995
+
1996
+ context 'with the :in option set to {state: state code}' do
1997
+ let(:location) { {state: state_code} }
1998
+ it { expect(clicks.keys.min).to eq date.to_date }
1999
+ end
2000
+
2001
+ context 'with the :in option set to {country: "US", state: state code}' do
2002
+ let(:location) { {country: 'US', state: state_code} }
2003
+ it { expect(clicks.keys.min).to eq date.to_date }
2004
+ end
2005
+ end
2006
+
2007
+ context 'and grouped by US state' do
2008
+ let(:by) { :state }
2009
+
2010
+ context 'with the :in option set to {state: state code}' do
2011
+ let(:location) { {state: state_code} }
2012
+ it { expect(clicks.keys).to eq [state_code] }
2013
+ end
2014
+
2015
+ context 'with the :in option set to {country: "US", state: state code}' do
2016
+ let(:location) { {country: 'US', state: state_code} }
2017
+ it { expect(clicks.keys).to eq [state_code] }
2018
+ end
2019
+ end
2020
+ end
2021
+
1698
2022
  describe 'annotation clicks can be grouped by range' do
1699
2023
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1700
2024
 
@@ -1754,6 +2078,88 @@ describe Yt::Video, :partner do
1754
2078
  end
1755
2079
  end
1756
2080
 
2081
+ describe 'annotation click_through_rate can be retrieved for a single country' do
2082
+ let(:country_code) { 'US' }
2083
+ let(:annotation_click_through_rate) { video.annotation_click_through_rate since: date, by: by, in: location }
2084
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2085
+
2086
+ context 'and grouped by day' do
2087
+ let(:by) { :day }
2088
+
2089
+ context 'with the :in option set to the country code' do
2090
+ let(:location) { country_code }
2091
+ it { expect(annotation_click_through_rate.keys.min).to eq date.to_date }
2092
+ end
2093
+
2094
+ context 'with the :in option set to {country: country code}' do
2095
+ let(:location) { {country: country_code} }
2096
+ it { expect(annotation_click_through_rate.keys.min).to eq date.to_date }
2097
+ end
2098
+ end
2099
+
2100
+ context 'and grouped by country' do
2101
+ let(:by) { :country }
2102
+
2103
+ context 'with the :in option set to the country code' do
2104
+ let(:location) { country_code }
2105
+ it { expect(annotation_click_through_rate.keys).to eq [country_code] }
2106
+ end
2107
+
2108
+ context 'with the :in option set to {country: country code}' do
2109
+ let(:location) { {country: country_code} }
2110
+ it { expect(annotation_click_through_rate.keys).to eq [country_code] }
2111
+ end
2112
+ end
2113
+
2114
+ context 'and grouped by state' do
2115
+ let(:by) { :state }
2116
+
2117
+ context 'with the :in option set to the country code' do
2118
+ let(:location) { country_code }
2119
+ it { expect(annotation_click_through_rate.keys.map(&:length).uniq).to eq [2] }
2120
+ end
2121
+
2122
+ context 'with the :in option set to {country: country code}' do
2123
+ let(:location) { {country: country_code} }
2124
+ it { expect(annotation_click_through_rate.keys.map(&:length).uniq).to eq [2] }
2125
+ end
2126
+ end
2127
+ end
2128
+
2129
+ describe 'annotation click_through_rate can be retrieved for a single US state' do
2130
+ let(:state_code) { 'CA' }
2131
+ let(:click_through_rate) { video.annotation_click_through_rate since: date, by: by, in: location }
2132
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2133
+
2134
+ context 'and grouped by day' do
2135
+ let(:by) { :day }
2136
+
2137
+ context 'with the :in option set to {state: state code}' do
2138
+ let(:location) { {state: state_code} }
2139
+ it { expect(click_through_rate.keys.min).to eq date.to_date }
2140
+ end
2141
+
2142
+ context 'with the :in option set to {country: "US", state: state code}' do
2143
+ let(:location) { {country: 'US', state: state_code} }
2144
+ it { expect(click_through_rate.keys.min).to eq date.to_date }
2145
+ end
2146
+ end
2147
+
2148
+ context 'and grouped by US state' do
2149
+ let(:by) { :state }
2150
+
2151
+ context 'with the :in option set to {state: state code}' do
2152
+ let(:location) { {state: state_code} }
2153
+ it { expect(click_through_rate.keys).to eq [state_code] }
2154
+ end
2155
+
2156
+ context 'with the :in option set to {country: "US", state: state code}' do
2157
+ let(:location) { {country: 'US', state: state_code} }
2158
+ it { expect(click_through_rate.keys).to eq [state_code] }
2159
+ end
2160
+ end
2161
+ end
2162
+
1757
2163
  describe 'annotation click-through rate can be grouped by range' do
1758
2164
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1759
2165
 
@@ -1813,6 +2219,88 @@ describe Yt::Video, :partner do
1813
2219
  end
1814
2220
  end
1815
2221
 
2222
+ describe 'annotation close_rate can be retrieved for a single country' do
2223
+ let(:country_code) { 'US' }
2224
+ let(:annotation_close_rate) { video.annotation_close_rate since: date, by: by, in: location }
2225
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2226
+
2227
+ context 'and grouped by day' do
2228
+ let(:by) { :day }
2229
+
2230
+ context 'with the :in option set to the country code' do
2231
+ let(:location) { country_code }
2232
+ it { expect(annotation_close_rate.keys.min).to eq date.to_date }
2233
+ end
2234
+
2235
+ context 'with the :in option set to {country: country code}' do
2236
+ let(:location) { {country: country_code} }
2237
+ it { expect(annotation_close_rate.keys.min).to eq date.to_date }
2238
+ end
2239
+ end
2240
+
2241
+ context 'and grouped by country' do
2242
+ let(:by) { :country }
2243
+
2244
+ context 'with the :in option set to the country code' do
2245
+ let(:location) { country_code }
2246
+ it { expect(annotation_close_rate.keys).to eq [country_code] }
2247
+ end
2248
+
2249
+ context 'with the :in option set to {country: country code}' do
2250
+ let(:location) { {country: country_code} }
2251
+ it { expect(annotation_close_rate.keys).to eq [country_code] }
2252
+ end
2253
+ end
2254
+
2255
+ context 'and grouped by state' do
2256
+ let(:by) { :state }
2257
+
2258
+ context 'with the :in option set to the country code' do
2259
+ let(:location) { country_code }
2260
+ it { expect(annotation_close_rate.keys.map(&:length).uniq).to eq [2] }
2261
+ end
2262
+
2263
+ context 'with the :in option set to {country: country code}' do
2264
+ let(:location) { {country: country_code} }
2265
+ it { expect(annotation_close_rate.keys.map(&:length).uniq).to eq [2] }
2266
+ end
2267
+ end
2268
+ end
2269
+
2270
+ describe 'annotation close_rate can be retrieved for a single US state' do
2271
+ let(:state_code) { 'CA' }
2272
+ let(:close_rate) { video.annotation_close_rate since: date, by: by, in: location }
2273
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2274
+
2275
+ context 'and grouped by day' do
2276
+ let(:by) { :day }
2277
+
2278
+ context 'with the :in option set to {state: state code}' do
2279
+ let(:location) { {state: state_code} }
2280
+ it { expect(close_rate.keys.min).to eq date.to_date }
2281
+ end
2282
+
2283
+ context 'with the :in option set to {country: "US", state: state code}' do
2284
+ let(:location) { {country: 'US', state: state_code} }
2285
+ it { expect(close_rate.keys.min).to eq date.to_date }
2286
+ end
2287
+ end
2288
+
2289
+ context 'and grouped by US state' do
2290
+ let(:by) { :state }
2291
+
2292
+ context 'with the :in option set to {state: state code}' do
2293
+ let(:location) { {state: state_code} }
2294
+ it { expect(close_rate.keys).to eq [state_code] }
2295
+ end
2296
+
2297
+ context 'with the :in option set to {country: "US", state: state code}' do
2298
+ let(:location) { {country: 'US', state: state_code} }
2299
+ it { expect(close_rate.keys).to eq [state_code] }
2300
+ end
2301
+ end
2302
+ end
2303
+
1816
2304
  describe 'annotation close rate can be grouped by range' do
1817
2305
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1818
2306
 
@@ -1887,7 +2375,39 @@ describe Yt::Video, :partner do
1887
2375
  end
1888
2376
  end
1889
2377
 
1890
- describe 'viewer_percentage can be grouped by gender' do
2378
+ describe 'viewer percentage can be retrieved for a single country' do
2379
+ let(:country_code) { 'US' }
2380
+ let(:viewer_percentage) { video.viewer_percentage since: date, in: location }
2381
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2382
+
2383
+ context 'with the :in option set to the country code' do
2384
+ let(:location) { country_code }
2385
+ it { expect(viewer_percentage.keys).to match_array [:female, :male] }
2386
+ end
2387
+
2388
+ context 'with the :in option set to {country: country code}' do
2389
+ let(:location) { {country: country_code} }
2390
+ it { expect(viewer_percentage.keys).to match_array [:female, :male] }
2391
+ end
2392
+ end
2393
+
2394
+ describe 'viewer percentage can be retrieved for a single US state' do
2395
+ let(:state_code) { 'CA' }
2396
+ let(:viewer_percentage) { video.viewer_percentage since: date, in: location }
2397
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
2398
+
2399
+ context 'with the :in option set to {state: state code}' do
2400
+ let(:location) { {state: state_code} }
2401
+ it { expect(viewer_percentage.keys).to match_array [:female, :male] }
2402
+ end
2403
+
2404
+ context 'with the :in option set to {country: "US", state: state code}' do
2405
+ let(:location) { {country: 'US', state: state_code} }
2406
+ it { expect(viewer_percentage.keys).to match_array [:female, :male] }
2407
+ end
2408
+ end
2409
+
2410
+ describe 'viewer percentage can be grouped by gender' do
1891
2411
  let(:range) { {since: 1.year.ago.to_date, until: 1.week.ago.to_date} }
1892
2412
  let(:keys) { range.values }
1893
2413