yt 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +13 -0
  4. data/README.md +8 -461
  5. data/lib/yt/actions/base.rb +1 -0
  6. data/lib/yt/associations/has_attribute.rb +2 -0
  7. data/lib/yt/associations/has_authentication.rb +2 -0
  8. data/lib/yt/associations/has_many.rb +1 -0
  9. data/lib/yt/associations/has_one.rb +1 -0
  10. data/lib/yt/associations/has_reports.rb +24 -18
  11. data/lib/yt/collections/authentications.rb +1 -0
  12. data/lib/yt/collections/content_details.rb +1 -0
  13. data/lib/yt/collections/content_owner_details.rb +1 -0
  14. data/lib/yt/collections/file_details.rb +1 -0
  15. data/lib/yt/collections/ids.rb +1 -0
  16. data/lib/yt/collections/live_streaming_details.rb +1 -0
  17. data/lib/yt/collections/players.rb +1 -0
  18. data/lib/yt/collections/ratings.rb +1 -0
  19. data/lib/yt/collections/reports.rb +25 -16
  20. data/lib/yt/collections/resources.rb +1 -0
  21. data/lib/yt/collections/resumable_sessions.rb +1 -0
  22. data/lib/yt/collections/snippets.rb +1 -0
  23. data/lib/yt/collections/statistics_sets.rb +1 -0
  24. data/lib/yt/collections/statuses.rb +1 -0
  25. data/lib/yt/collections/subscriptions.rb +1 -0
  26. data/lib/yt/collections/user_infos.rb +1 -0
  27. data/lib/yt/models/account.rb +28 -26
  28. data/lib/yt/models/base.rb +1 -0
  29. data/lib/yt/models/channel.rb +38 -38
  30. data/lib/yt/models/content_detail.rb +1 -0
  31. data/lib/yt/models/content_owner_detail.rb +1 -0
  32. data/lib/yt/models/device_flow.rb +1 -0
  33. data/lib/yt/models/file_detail.rb +1 -0
  34. data/lib/yt/models/iterator.rb +1 -0
  35. data/lib/yt/models/live_streaming_detail.rb +1 -0
  36. data/lib/yt/models/player.rb +1 -0
  37. data/lib/yt/models/playlist.rb +19 -19
  38. data/lib/yt/models/playlist_item.rb +12 -12
  39. data/lib/yt/models/rating.rb +1 -0
  40. data/lib/yt/models/resource.rb +8 -2
  41. data/lib/yt/models/resumable_session.rb +1 -0
  42. data/lib/yt/models/snippet.rb +1 -0
  43. data/lib/yt/models/statistics_set.rb +1 -0
  44. data/lib/yt/models/status.rb +1 -6
  45. data/lib/yt/models/subscription.rb +1 -0
  46. data/lib/yt/models/timestamp.rb +1 -0
  47. data/lib/yt/models/url.rb +1 -0
  48. data/lib/yt/models/user_info.rb +1 -0
  49. data/lib/yt/models/video.rb +70 -70
  50. data/lib/yt/models/video_category.rb +1 -0
  51. data/lib/yt/request.rb +1 -0
  52. data/lib/yt/version.rb +1 -1
  53. data/spec/collections/reports_spec.rb +1 -1
  54. data/spec/requests/as_content_owner/channel_spec.rb +210 -14
  55. data/spec/requests/as_content_owner/playlist_spec.rb +68 -8
  56. data/spec/requests/as_content_owner/video_spec.rb +213 -16
  57. data/spec/requests/as_server_app/channel_spec.rb +27 -7
  58. data/spec/requests/as_server_app/playlist_spec.rb +25 -4
  59. data/spec/requests/as_server_app/video_spec.rb +26 -5
  60. metadata +1 -3
  61. data/spec/requests/as_server_app/resource_spec.rb +0 -46
@@ -55,10 +55,36 @@ describe Yt::Channel, :partner do
55
55
  end
56
56
  end
57
57
 
58
+ describe 'earnings can be grouped by range' do
59
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
60
+ let(:keys) { range.values }
61
+
62
+ specify 'with the :by option set to :range' do
63
+ earnings = channel.earnings range.merge by: :range
64
+ expect(earnings.size).to be 1
65
+ expect(earnings[:total]).to be_a Float
66
+ end
67
+ end
68
+
69
+ describe 'earnings can be grouped by day' do
70
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
71
+ let(:keys) { range.values }
72
+
73
+ specify 'without a :by option (default)' do
74
+ earnings = channel.earnings range
75
+ expect(earnings.keys).to eq range.values
76
+ end
77
+
78
+ specify 'with the :by option set to :day' do
79
+ earnings = channel.earnings range.merge by: :day
80
+ expect(earnings.keys).to eq range.values
81
+ end
82
+ end
83
+
58
84
  describe 'views can be retrieved for a specific day' do
59
85
  context 'in which the channel was partnered' do
60
86
  let(:views) { channel.views_on 5.days.ago}
61
- it { expect(views).to be_a Float }
87
+ it { expect(views).to be_an Integer }
62
88
  end
63
89
 
64
90
  context 'in which the channel was not partnered' do
@@ -87,6 +113,16 @@ describe Yt::Channel, :partner do
87
113
  end
88
114
  end
89
115
 
116
+ describe 'views can be grouped by range' do
117
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
118
+
119
+ specify 'with the :by option set to :range' do
120
+ views = channel.views range.merge by: :range
121
+ expect(views.size).to be 1
122
+ expect(views[:total]).to be_an Integer
123
+ end
124
+ end
125
+
90
126
  describe 'views can be grouped by day' do
91
127
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
92
128
  let(:keys) { range.values }
@@ -164,14 +200,14 @@ describe Yt::Channel, :partner do
164
200
  specify 'with the :by option set to :device_type' do
165
201
  views = channel.views range.merge by: :device_type
166
202
  expect(views.keys).to all(be_instance_of Symbol)
167
- expect(views.values).to all(be_instance_of Float)
203
+ expect(views.values).to all(be_an Integer)
168
204
  end
169
205
  end
170
206
 
171
207
  describe 'comments can be retrieved for a specific day' do
172
208
  context 'in which the channel was partnered' do
173
209
  let(:comments) { channel.comments_on 5.days.ago}
174
- it { expect(comments).to be_a Float }
210
+ it { expect(comments).to be_an Integer }
175
211
  end
176
212
 
177
213
  context 'in which the channel was not partnered' do
@@ -200,6 +236,16 @@ describe Yt::Channel, :partner do
200
236
  end
201
237
  end
202
238
 
239
+ describe 'comments can be grouped by range' do
240
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
241
+
242
+ specify 'with the :by option set to :range' do
243
+ comments = channel.comments range.merge by: :range
244
+ expect(comments.size).to be 1
245
+ expect(comments[:total]).to be_an Integer
246
+ end
247
+ end
248
+
203
249
  describe 'comments can be grouped by day' do
204
250
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
205
251
  let(:keys) { range.values }
@@ -218,7 +264,7 @@ describe Yt::Channel, :partner do
218
264
  describe 'likes can be retrieved for a specific day' do
219
265
  context 'in which the channel was partnered' do
220
266
  let(:likes) { channel.likes_on 5.days.ago}
221
- it { expect(likes).to be_a Float }
267
+ it { expect(likes).to be_an Integer }
222
268
  end
223
269
 
224
270
  context 'in which the channel was not partnered' do
@@ -247,6 +293,16 @@ describe Yt::Channel, :partner do
247
293
  end
248
294
  end
249
295
 
296
+ describe 'likes can be grouped by range' do
297
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
298
+
299
+ specify 'with the :by option set to :range' do
300
+ likes = channel.likes range.merge by: :range
301
+ expect(likes.size).to be 1
302
+ expect(likes[:total]).to be_an Integer
303
+ end
304
+ end
305
+
250
306
  describe 'likes can be grouped by day' do
251
307
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
252
308
  let(:keys) { range.values }
@@ -265,7 +321,7 @@ describe Yt::Channel, :partner do
265
321
  describe 'dislikes can be retrieved for a specific day' do
266
322
  context 'in which the channel was partnered' do
267
323
  let(:dislikes) { channel.dislikes_on 5.days.ago}
268
- it { expect(dislikes).to be_a Float }
324
+ it { expect(dislikes).to be_an Integer }
269
325
  end
270
326
 
271
327
  context 'in which the channel was not partnered' do
@@ -294,6 +350,16 @@ describe Yt::Channel, :partner do
294
350
  end
295
351
  end
296
352
 
353
+ describe 'dislikes can be grouped by range' do
354
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
355
+
356
+ specify 'with the :by option set to :range' do
357
+ dislikes = channel.dislikes range.merge by: :range
358
+ expect(dislikes.size).to be 1
359
+ expect(dislikes[:total]).to be_an Integer
360
+ end
361
+ end
362
+
297
363
  describe 'dislikes can be grouped by day' do
298
364
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
299
365
  let(:keys) { range.values }
@@ -312,7 +378,7 @@ describe Yt::Channel, :partner do
312
378
  describe 'shares can be retrieved for a specific day' do
313
379
  context 'in which the channel was partnered' do
314
380
  let(:shares) { channel.shares_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
315
- it { expect(shares).to be_a Float }
381
+ it { expect(shares).to be_an Integer }
316
382
  end
317
383
 
318
384
  context 'in which the channel was not partnered' do
@@ -341,6 +407,16 @@ describe Yt::Channel, :partner do
341
407
  end
342
408
  end
343
409
 
410
+ describe 'shares can be grouped by range' do
411
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
412
+
413
+ specify 'with the :by option set to :range' do
414
+ shares = channel.shares range.merge by: :range
415
+ expect(shares.size).to be 1
416
+ expect(shares[:total]).to be_an Integer
417
+ end
418
+ end
419
+
344
420
  describe 'shares can be grouped by day' do
345
421
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
346
422
  let(:keys) { range.values }
@@ -359,7 +435,7 @@ describe Yt::Channel, :partner do
359
435
  describe 'gained subscribers can be retrieved for a specific day' do
360
436
  context 'in which the channel was partnered' do
361
437
  let(:subscribers_gained) { channel.subscribers_gained_on 5.days.ago}
362
- it { expect(subscribers_gained).to be_a Float }
438
+ it { expect(subscribers_gained).to be_an Integer }
363
439
  end
364
440
 
365
441
  context 'in which the channel was not partnered' do
@@ -388,6 +464,16 @@ describe Yt::Channel, :partner do
388
464
  end
389
465
  end
390
466
 
467
+ describe 'gained subscribers can be grouped by range' do
468
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
469
+
470
+ specify 'with the :by option set to :range' do
471
+ subscribers_gained = channel.subscribers_gained range.merge by: :range
472
+ expect(subscribers_gained.size).to be 1
473
+ expect(subscribers_gained[:total]).to be_an Integer
474
+ end
475
+ end
476
+
391
477
  describe 'gained subscribers can be grouped by day' do
392
478
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
393
479
  let(:keys) { range.values }
@@ -406,7 +492,7 @@ describe Yt::Channel, :partner do
406
492
  describe 'lost subscribers can be retrieved for a specific day' do
407
493
  context 'in which the channel was partnered' do
408
494
  let(:subscribers_lost) { channel.subscribers_lost_on 5.days.ago}
409
- it { expect(subscribers_lost).to be_a Float }
495
+ it { expect(subscribers_lost).to be_an Integer }
410
496
  end
411
497
 
412
498
  context 'in which the channel was not partnered' do
@@ -435,6 +521,16 @@ describe Yt::Channel, :partner do
435
521
  end
436
522
  end
437
523
 
524
+ describe 'lost subscribers can be grouped by range' do
525
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
526
+
527
+ specify 'with the :by option set to :range' do
528
+ subscribers_lost = channel.subscribers_lost range.merge by: :range
529
+ expect(subscribers_lost.size).to be 1
530
+ expect(subscribers_lost[:total]).to be_an Integer
531
+ end
532
+ end
533
+
438
534
  describe 'lost subscribers can be grouped by day' do
439
535
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
440
536
  let(:keys) { range.values }
@@ -453,7 +549,7 @@ describe Yt::Channel, :partner do
453
549
  describe 'added favorites can be retrieved for a specific day' do
454
550
  context 'in which the channel was partnered' do
455
551
  let(:favorites_added) { channel.favorites_added_on 5.days.ago}
456
- it { expect(favorites_added).to be_a Float }
552
+ it { expect(favorites_added).to be_an Integer }
457
553
  end
458
554
 
459
555
  context 'in which the channel was not partnered' do
@@ -482,6 +578,16 @@ describe Yt::Channel, :partner do
482
578
  end
483
579
  end
484
580
 
581
+ describe 'added favorites can be grouped by range' do
582
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
583
+
584
+ specify 'with the :by option set to :range' do
585
+ favorites_added = channel.favorites_added range.merge by: :range
586
+ expect(favorites_added.size).to be 1
587
+ expect(favorites_added[:total]).to be_an Integer
588
+ end
589
+ end
590
+
485
591
  describe 'added favorites can be grouped by day' do
486
592
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
487
593
  let(:keys) { range.values }
@@ -500,7 +606,7 @@ describe Yt::Channel, :partner do
500
606
  describe 'removed favorites can be retrieved for a specific day' do
501
607
  context 'in which the channel was partnered' do
502
608
  let(:favorites_removed) { channel.favorites_removed_on 5.days.ago}
503
- it { expect(favorites_removed).to be_a Float }
609
+ it { expect(favorites_removed).to be_an Integer }
504
610
  end
505
611
 
506
612
  context 'in which the channel was not partnered' do
@@ -529,6 +635,16 @@ describe Yt::Channel, :partner do
529
635
  end
530
636
  end
531
637
 
638
+ describe 'removed favorites can be grouped by range' do
639
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
640
+
641
+ specify 'with the :by option set to :range' do
642
+ favorites_removed = channel.favorites_removed range.merge by: :range
643
+ expect(favorites_removed.size).to be 1
644
+ expect(favorites_removed[:total]).to be_an Integer
645
+ end
646
+ end
647
+
532
648
  describe 'removed favorites can be grouped by day' do
533
649
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
534
650
  let(:keys) { range.values }
@@ -576,6 +692,16 @@ describe Yt::Channel, :partner do
576
692
  end
577
693
  end
578
694
 
695
+ describe 'estimated minutes watched can be grouped by range' do
696
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
697
+
698
+ specify 'with the :by option set to :range' do
699
+ minutes = channel.estimated_minutes_watched range.merge by: :range
700
+ expect(minutes.size).to be 1
701
+ expect(minutes[:total]).to be_a Float
702
+ end
703
+ end
704
+
579
705
  describe 'estimated minutes watched can be grouped by day' do
580
706
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
581
707
  let(:keys) { range.values }
@@ -689,6 +815,16 @@ describe Yt::Channel, :partner do
689
815
  end
690
816
  end
691
817
 
818
+ describe 'average view duration can be grouped by range' do
819
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
820
+
821
+ specify 'with the :by option set to :range' do
822
+ duration = channel.average_view_duration range.merge by: :range
823
+ expect(duration.size).to be 1
824
+ expect(duration[:total]).to be_a Float
825
+ end
826
+ end
827
+
692
828
  describe 'average view duration can be grouped by day' do
693
829
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
694
830
  let(:keys) { range.values }
@@ -736,6 +872,16 @@ describe Yt::Channel, :partner do
736
872
  end
737
873
  end
738
874
 
875
+ describe 'average view percentage can be grouped by range' do
876
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
877
+
878
+ specify 'with the :by option set to :range' do
879
+ percentage = channel.average_view_percentage range.merge by: :range
880
+ expect(percentage.size).to be 1
881
+ expect(percentage[:total]).to be_a Float
882
+ end
883
+ end
884
+
739
885
  describe 'average view percentage can be grouped by day' do
740
886
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
741
887
  let(:keys) { range.values }
@@ -754,7 +900,7 @@ describe Yt::Channel, :partner do
754
900
  describe 'impressions can be retrieved for a specific day' do
755
901
  context 'in which the channel was partnered' do
756
902
  let(:impressions) { channel.impressions_on 20.days.ago}
757
- it { expect(impressions).to be_a Float }
903
+ it { expect(impressions).to be_an Integer }
758
904
  end
759
905
 
760
906
  context 'in which the channel was not partnered' do
@@ -783,6 +929,16 @@ describe Yt::Channel, :partner do
783
929
  end
784
930
  end
785
931
 
932
+ describe 'impressions can be grouped by range' do
933
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
934
+
935
+ specify 'with the :by option set to :range' do
936
+ impressions = channel.impressions range.merge by: :range
937
+ expect(impressions.size).to be 1
938
+ expect(impressions[:total]).to be_an Integer
939
+ end
940
+ end
941
+
786
942
  describe 'impressions can be grouped by day' do
787
943
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
788
944
  let(:keys) { range.values }
@@ -801,7 +957,7 @@ describe Yt::Channel, :partner do
801
957
  describe 'monetized playbacks can be retrieved for a specific day' do
802
958
  context 'in which the channel was partnered' do
803
959
  let(:monetized_playbacks) { channel.monetized_playbacks_on 20.days.ago}
804
- it { expect(monetized_playbacks).to be_a Float }
960
+ it { expect(monetized_playbacks).to be_an Integer }
805
961
  end
806
962
 
807
963
  context 'in which the channel was not partnered' do
@@ -830,6 +986,16 @@ describe Yt::Channel, :partner do
830
986
  end
831
987
  end
832
988
 
989
+ describe 'monetized playbacks can be grouped by range' do
990
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
991
+
992
+ specify 'with the :by option set to :range' do
993
+ monetized_playbacks = channel.monetized_playbacks range.merge by: :range
994
+ expect(monetized_playbacks.size).to be 1
995
+ expect(monetized_playbacks[:total]).to be_an Integer
996
+ end
997
+ end
998
+
833
999
  describe 'monetized_playbacks can be grouped by day' do
834
1000
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
835
1001
  let(:keys) { range.values }
@@ -858,17 +1024,27 @@ describe Yt::Channel, :partner do
858
1024
  end
859
1025
  end
860
1026
 
1027
+ describe 'annotation clicks can be grouped by range' do
1028
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1029
+
1030
+ specify 'with the :by option set to :range' do
1031
+ annotation_clicks = channel.annotation_clicks range.merge by: :range
1032
+ expect(annotation_clicks.size).to be 1
1033
+ expect(annotation_clicks[:total]).to be_an Integer
1034
+ end
1035
+ end
1036
+
861
1037
  describe 'annotation clicks can be grouped by day' do
862
1038
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
863
1039
 
864
1040
  specify 'without a :by option (default)' do
865
1041
  annotation_clicks = channel.annotation_clicks range
866
- expect(annotation_clicks.values).to all(be_instance_of Float)
1042
+ expect(annotation_clicks.values).to all(be_an Integer)
867
1043
  end
868
1044
 
869
1045
  specify 'with the :by option set to :day' do
870
1046
  annotation_clicks = channel.annotation_clicks range.merge by: :day
871
- expect(annotation_clicks.values).to all(be_instance_of Float)
1047
+ expect(annotation_clicks.values).to all(be_an Integer)
872
1048
  end
873
1049
  end
874
1050
 
@@ -885,6 +1061,16 @@ describe Yt::Channel, :partner do
885
1061
  end
886
1062
  end
887
1063
 
1064
+ describe 'annotation click-through rate can be grouped by range' do
1065
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1066
+
1067
+ specify 'with the :by option set to :range' do
1068
+ rate = channel.annotation_click_through_rate range.merge by: :range
1069
+ expect(rate.size).to be 1
1070
+ expect(rate[:total]).to be_a Float
1071
+ end
1072
+ end
1073
+
888
1074
  describe 'annotation click-through rate can be grouped by day' do
889
1075
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
890
1076
 
@@ -912,6 +1098,16 @@ describe Yt::Channel, :partner do
912
1098
  end
913
1099
  end
914
1100
 
1101
+ describe 'annotation close rate can be grouped by range' do
1102
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1103
+
1104
+ specify 'with the :by option set to :range' do
1105
+ rate = channel.annotation_close_rate range.merge by: :range
1106
+ expect(rate.size).to be 1
1107
+ expect(rate[:total]).to be_a Float
1108
+ end
1109
+ end
1110
+
915
1111
  describe 'annotation close rate can be grouped by day' do
916
1112
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
917
1113
 
@@ -13,7 +13,7 @@ describe Yt::Playlist, :partner do
13
13
  describe 'views can be retrieved for a specific day' do
14
14
  context 'in which the playlist was viewed' do
15
15
  let(:views) { playlist.views_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
16
- it { expect(views).to be_a Float }
16
+ it { expect(views).to be_an Integer }
17
17
  end
18
18
 
19
19
  context 'in which the playlist was not viewed' do
@@ -42,6 +42,16 @@ describe Yt::Playlist, :partner do
42
42
  end
43
43
  end
44
44
 
45
+ describe 'views can be grouped by range' do
46
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
47
+
48
+ specify 'with the :by option set to :range' do
49
+ views = playlist.views range.merge by: :range
50
+ expect(views.size).to be 1
51
+ expect(views[:total]).to be_an Integer
52
+ end
53
+ end
54
+
45
55
  describe 'views can be grouped by day' do
46
56
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
47
57
  let(:keys) { range.values }
@@ -110,19 +120,19 @@ describe Yt::Playlist, :partner do
110
120
  specify 'with the :by option set to :device_type' do
111
121
  views = playlist.views range.merge by: :device_type
112
122
  expect(views.keys).to all(be_instance_of Symbol)
113
- expect(views.values).to all(be_instance_of Float)
123
+ expect(views.values).to all(be_an Integer)
114
124
  end
115
125
  end
116
126
 
117
127
  describe 'estimated minutes watched can be retrieved for a specific day' do
118
128
  context 'in which the playlist was viewed' do
119
- let(:views) { playlist.estimated_minutes_watched_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
120
- it { expect(views).to be_a Float }
129
+ let(:minutes) { playlist.estimated_minutes_watched_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
130
+ it { expect(minutes).to be_a Float }
121
131
  end
122
132
 
123
133
  context 'in which the playlist was not viewed' do
124
- let(:views) { playlist.estimated_minutes_watched_on 20.years.ago}
125
- it { expect(views).to be_nil }
134
+ let(:minutes) { playlist.estimated_minutes_watched_on 20.years.ago}
135
+ it { expect(minutes).to be_nil }
126
136
  end
127
137
  end
128
138
 
@@ -146,6 +156,16 @@ describe Yt::Playlist, :partner do
146
156
  end
147
157
  end
148
158
 
159
+ describe 'estimated minutes watched can be grouped by range' do
160
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
161
+
162
+ specify 'with the :by option set to :range' do
163
+ minutes = playlist.estimated_minutes_watched range.merge by: :range
164
+ expect(minutes.size).to be 1
165
+ expect(minutes[:total]).to be_a Float
166
+ end
167
+ end
168
+
149
169
  describe 'estimated minutes watched can be grouped by day' do
150
170
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
151
171
  let(:keys) { range.values }
@@ -271,7 +291,7 @@ describe Yt::Playlist, :partner do
271
291
 
272
292
  describe 'average view duration can be retrieved for a specific day' do
273
293
  context 'in which the playlist was partnered' do
274
- let(:average_view_duration) { playlist.average_view_duration_on 5.days.ago}
294
+ let(:average_view_duration) { playlist.average_view_duration_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
275
295
  it { expect(average_view_duration).to be_a Float }
276
296
  end
277
297
 
@@ -301,6 +321,16 @@ describe Yt::Playlist, :partner do
301
321
  end
302
322
  end
303
323
 
324
+ describe 'average view duration can be grouped by range' do
325
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
326
+
327
+ specify 'with the :by option set to :range' do
328
+ duration = playlist.average_view_duration range.merge by: :range
329
+ expect(duration.size).to be 1
330
+ expect(duration[:total]).to be_a Float
331
+ end
332
+ end
333
+
304
334
  describe 'average view duration can be grouped by day' do
305
335
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
306
336
  let(:keys) { range.values }
@@ -319,7 +349,7 @@ describe Yt::Playlist, :partner do
319
349
  describe 'playlist starts can be retrieved for a specific day' do
320
350
  context 'in which the playlist was viewed' do
321
351
  let(:playlist_starts) { playlist.playlist_starts_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
322
- it { expect(playlist_starts).to be_a Float }
352
+ it { expect(playlist_starts).to be_an Integer }
323
353
  end
324
354
 
325
355
  context 'in which the playlist was not viewed' do
@@ -348,6 +378,16 @@ describe Yt::Playlist, :partner do
348
378
  end
349
379
  end
350
380
 
381
+ describe 'playlist starts can be grouped by range' do
382
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
383
+
384
+ specify 'with the :by option set to :range' do
385
+ playlist_starts = playlist.playlist_starts range.merge by: :range
386
+ expect(playlist_starts.size).to be 1
387
+ expect(playlist_starts[:total]).to be_an Integer
388
+ end
389
+ end
390
+
351
391
  describe 'playlist starts can be grouped by day' do
352
392
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
353
393
  let(:keys) { range.values }
@@ -395,6 +435,16 @@ describe Yt::Playlist, :partner do
395
435
  end
396
436
  end
397
437
 
438
+ describe 'average time in playlist can be grouped by range' do
439
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
440
+
441
+ specify 'with the :by option set to :range' do
442
+ times = playlist.average_time_in_playlist range.merge by: :range
443
+ expect(times.size).to be 1
444
+ expect(times[:total]).to be_a Float
445
+ end
446
+ end
447
+
398
448
  describe 'average time in playlist can be grouped by day' do
399
449
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
400
450
  let(:keys) { range.values }
@@ -442,6 +492,16 @@ describe Yt::Playlist, :partner do
442
492
  end
443
493
  end
444
494
 
495
+ describe 'views per playlist start can be grouped by range' do
496
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
497
+
498
+ specify 'with the :by option set to :range' do
499
+ views = playlist.views_per_playlist_start range.merge by: :range
500
+ expect(views.size).to be 1
501
+ expect(views[:total]).to be_a Float
502
+ end
503
+ end
504
+
445
505
  describe 'views per playlist start can be grouped by day' do
446
506
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
447
507
  let(:keys) { range.values }