yt 0.21.0 → 0.22.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 (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
@@ -37,10 +37,36 @@ describe Yt::Video, :partner do
37
37
  end
38
38
  end
39
39
 
40
+ describe 'earnings can be grouped by range' do
41
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
42
+ let(:keys) { range.values }
43
+
44
+ specify 'with the :by option set to :range' do
45
+ earnings = video.earnings range.merge by: :range
46
+ expect(earnings.size).to be 1
47
+ expect(earnings[:total]).to be_a Float
48
+ end
49
+ end
50
+
51
+ describe 'earnings can be grouped by day' do
52
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
53
+ let(:keys) { range.values }
54
+
55
+ specify 'without a :by option (default)' do
56
+ earnings = video.earnings range
57
+ expect(earnings.keys).to eq range.values
58
+ end
59
+
60
+ specify 'with the :by option set to :day' do
61
+ earnings = video.earnings range.merge by: :day
62
+ expect(earnings.keys).to eq range.values
63
+ end
64
+ end
65
+
40
66
  describe 'views can be retrieved for a specific day' do
41
67
  context 'in which the video was partnered' do
42
68
  let(:views) { video.views_on 5.days.ago}
43
- it { expect(views).to be_a Float }
69
+ it { expect(views).to be_an Integer }
44
70
  end
45
71
 
46
72
  context 'in which the video was not partnered' do
@@ -69,6 +95,16 @@ describe Yt::Video, :partner do
69
95
  end
70
96
  end
71
97
 
98
+ describe 'views can be grouped by range' do
99
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
100
+
101
+ specify 'with the :by option set to :range' do
102
+ views = video.views range.merge by: :range
103
+ expect(views.size).to be 1
104
+ expect(views[:total]).to be_an Integer
105
+ end
106
+ end
107
+
72
108
  describe 'views can be grouped by day' do
73
109
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
74
110
  let(:keys) { range.values }
@@ -128,14 +164,14 @@ describe Yt::Video, :partner do
128
164
  specify 'with the :by option set to :device_type' do
129
165
  views = video.views range.merge by: :device_type
130
166
  expect(views.keys).to all(be_instance_of Symbol)
131
- expect(views.values).to all(be_instance_of Float)
167
+ expect(views.values).to all(be_an Integer)
132
168
  end
133
169
  end
134
170
 
135
171
  describe 'comments can be retrieved for a specific day' do
136
172
  context 'in which the video was partnered' do
137
173
  let(:comments) { video.comments_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
138
- it { expect(comments).to be_a Float }
174
+ it { expect(comments).to be_an Integer }
139
175
  end
140
176
 
141
177
  context 'in which the video was not partnered' do
@@ -164,6 +200,16 @@ describe Yt::Video, :partner do
164
200
  end
165
201
  end
166
202
 
203
+ describe 'comments can be grouped by range' do
204
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
205
+
206
+ specify 'with the :by option set to :range' do
207
+ comments = video.comments range.merge by: :range
208
+ expect(comments.size).to be 1
209
+ expect(comments[:total]).to be_an Integer
210
+ end
211
+ end
212
+
167
213
  describe 'comments can be grouped by day' do
168
214
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
169
215
  let(:keys) { range.values }
@@ -182,7 +228,7 @@ describe Yt::Video, :partner do
182
228
  describe 'likes can be retrieved for a specific day' do
183
229
  context 'in which the video was partnered' do
184
230
  let(:likes) { video.likes_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
185
- it { expect(likes).to be_a Float }
231
+ it { expect(likes).to be_an Integer }
186
232
  end
187
233
 
188
234
  context 'in which the video was not partnered' do
@@ -211,6 +257,16 @@ describe Yt::Video, :partner do
211
257
  end
212
258
  end
213
259
 
260
+ describe 'likes can be grouped by range' do
261
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
262
+
263
+ specify 'with the :by option set to :range' do
264
+ likes = video.likes range.merge by: :range
265
+ expect(likes.size).to be 1
266
+ expect(likes[:total]).to be_an Integer
267
+ end
268
+ end
269
+
214
270
  describe 'likes can be grouped by day' do
215
271
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
216
272
  let(:keys) { range.values }
@@ -229,7 +285,7 @@ describe Yt::Video, :partner do
229
285
  describe 'dislikes can be retrieved for a specific day' do
230
286
  context 'in which the video was partnered' do
231
287
  let(:dislikes) { video.dislikes_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
232
- it { expect(dislikes).to be_a Float }
288
+ it { expect(dislikes).to be_an Integer }
233
289
  end
234
290
 
235
291
  context 'in which the video was not partnered' do
@@ -258,6 +314,16 @@ describe Yt::Video, :partner do
258
314
  end
259
315
  end
260
316
 
317
+ describe 'dislikes can be grouped by range' do
318
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
319
+
320
+ specify 'with the :by option set to :range' do
321
+ dislikes = video.dislikes range.merge by: :range
322
+ expect(dislikes.size).to be 1
323
+ expect(dislikes[:total]).to be_an Integer
324
+ end
325
+ end
326
+
261
327
  describe 'dislikes can be grouped by day' do
262
328
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
263
329
  let(:keys) { range.values }
@@ -276,7 +342,7 @@ describe Yt::Video, :partner do
276
342
  describe 'shares can be retrieved for a specific day' do
277
343
  context 'in which the video was partnered' do
278
344
  let(:shares) { video.shares_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
279
- it { expect(shares).to be_a Float }
345
+ it { expect(shares).to be_an Integer }
280
346
  end
281
347
 
282
348
  context 'in which the video was not partnered' do
@@ -305,6 +371,16 @@ describe Yt::Video, :partner do
305
371
  end
306
372
  end
307
373
 
374
+ describe 'shares can be grouped by range' do
375
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
376
+
377
+ specify 'with the :by option set to :range' do
378
+ shares = video.shares range.merge by: :range
379
+ expect(shares.size).to be 1
380
+ expect(shares[:total]).to be_an Integer
381
+ end
382
+ end
383
+
308
384
  describe 'shares can be grouped by day' do
309
385
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
310
386
  let(:keys) { range.values }
@@ -323,7 +399,7 @@ describe Yt::Video, :partner do
323
399
  describe 'gained subscribers can be retrieved for a specific day' do
324
400
  context 'in which the video was partnered' do
325
401
  let(:subscribers_gained) { video.subscribers_gained_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
326
- it { expect(subscribers_gained).to be_a Float }
402
+ it { expect(subscribers_gained).to be_an Integer }
327
403
  end
328
404
 
329
405
  context 'in which the video was not partnered' do
@@ -352,6 +428,16 @@ describe Yt::Video, :partner do
352
428
  end
353
429
  end
354
430
 
431
+ describe 'gained subscribers can be grouped by range' do
432
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
433
+
434
+ specify 'with the :by option set to :range' do
435
+ subscribers_gained = video.subscribers_gained range.merge by: :range
436
+ expect(subscribers_gained.size).to be 1
437
+ expect(subscribers_gained[:total]).to be_an Integer
438
+ end
439
+ end
440
+
355
441
  describe 'gained subscribers can be grouped by day' do
356
442
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
357
443
  let(:keys) { range.values }
@@ -370,7 +456,7 @@ describe Yt::Video, :partner do
370
456
  describe 'lost subscribers can be retrieved for a specific day' do
371
457
  context 'in which the video was partnered' do
372
458
  let(:subscribers_lost) { video.subscribers_lost_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
373
- it { expect(subscribers_lost).to be_a Float }
459
+ it { expect(subscribers_lost).to be_an Integer }
374
460
  end
375
461
 
376
462
  context 'in which the video was not partnered' do
@@ -399,6 +485,16 @@ describe Yt::Video, :partner do
399
485
  end
400
486
  end
401
487
 
488
+ describe 'lost subscribers can be grouped by range' do
489
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
490
+
491
+ specify 'with the :by option set to :range' do
492
+ subscribers_lost = video.subscribers_lost range.merge by: :range
493
+ expect(subscribers_lost.size).to be 1
494
+ expect(subscribers_lost[:total]).to be_an Integer
495
+ end
496
+ end
497
+
402
498
  describe 'lost subscribers can be grouped by day' do
403
499
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
404
500
  let(:keys) { range.values }
@@ -417,7 +513,7 @@ describe Yt::Video, :partner do
417
513
  describe 'added favorites can be retrieved for a specific day' do
418
514
  context 'in which the video was partnered' do
419
515
  let(:favorites_added) { video.favorites_added_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
420
- it { expect(favorites_added).to be_a Float }
516
+ it { expect(favorites_added).to be_an Integer }
421
517
  end
422
518
 
423
519
  context 'in which the video was not partnered' do
@@ -446,6 +542,16 @@ describe Yt::Video, :partner do
446
542
  end
447
543
  end
448
544
 
545
+ describe 'added favorites can be grouped by range' do
546
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
547
+
548
+ specify 'with the :by option set to :range' do
549
+ favorites_added = video.favorites_added range.merge by: :range
550
+ expect(favorites_added.size).to be 1
551
+ expect(favorites_added[:total]).to be_an Integer
552
+ end
553
+ end
554
+
449
555
  describe 'added favorites can be grouped by day' do
450
556
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
451
557
  let(:keys) { range.values }
@@ -464,7 +570,7 @@ describe Yt::Video, :partner do
464
570
  describe 'removed favorites can be retrieved for a specific day' do
465
571
  context 'in which the video was partnered' do
466
572
  let(:favorites_removed) { video.favorites_removed_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
467
- it { expect(favorites_removed).to be_a Float }
573
+ it { expect(favorites_removed).to be_an Integer }
468
574
  end
469
575
 
470
576
  context 'in which the video was not partnered' do
@@ -493,6 +599,17 @@ describe Yt::Video, :partner do
493
599
  end
494
600
  end
495
601
 
602
+ describe 'removed favorites can be grouped by range' do
603
+ let(:id) { 'NeMlqbX2Ifg' }
604
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
605
+
606
+ specify 'with the :by option set to :range' do
607
+ favorites_removed = video.favorites_removed range.merge by: :range
608
+ expect(favorites_removed.size).to be 1
609
+ expect(favorites_removed[:total]).to be_an Integer
610
+ end
611
+ end
612
+
496
613
  describe 'removed favorites can be grouped by day' do
497
614
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
498
615
  let(:keys) { range.values }
@@ -540,6 +657,16 @@ describe Yt::Video, :partner do
540
657
  end
541
658
  end
542
659
 
660
+ describe 'estimated minutes watched can be grouped by range' do
661
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
662
+
663
+ specify 'with the :by option set to :range' do
664
+ minutes = video.estimated_minutes_watched range.merge by: :range
665
+ expect(minutes.size).to be 1
666
+ expect(minutes[:total]).to be_a Float
667
+ end
668
+ end
669
+
543
670
  describe 'estimated minutes watched can be grouped by day' do
544
671
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
545
672
  let(:keys) { range.values }
@@ -635,6 +762,16 @@ describe Yt::Video, :partner do
635
762
  end
636
763
  end
637
764
 
765
+ describe 'average view duration can be grouped by range' do
766
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
767
+
768
+ specify 'with the :by option set to :range' do
769
+ duration = video.average_view_duration range.merge by: :range
770
+ expect(duration.size).to be 1
771
+ expect(duration[:total]).to be_a Float
772
+ end
773
+ end
774
+
638
775
  describe 'average view duration can be grouped by day' do
639
776
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
640
777
  let(:keys) { range.values }
@@ -682,6 +819,16 @@ describe Yt::Video, :partner do
682
819
  end
683
820
  end
684
821
 
822
+ describe 'average view percentage can be grouped by range' do
823
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
824
+
825
+ specify 'with the :by option set to :range' do
826
+ percentage = video.average_view_percentage range.merge by: :range
827
+ expect(percentage.size).to be 1
828
+ expect(percentage[:total]).to be_a Float
829
+ end
830
+ end
831
+
685
832
  describe 'average view percentage can be grouped by day' do
686
833
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
687
834
  let(:keys) { range.values }
@@ -699,8 +846,8 @@ describe Yt::Video, :partner do
699
846
 
700
847
  describe 'impressions can be retrieved for a specific day' do
701
848
  context 'in which the video was partnered' do
702
- let(:impressions) { video.impressions_on 20.days.ago}
703
- it { expect(impressions).to be_a Float }
849
+ let(:impressions) { video.impressions_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
850
+ it { expect(impressions).to be_an Integer }
704
851
  end
705
852
 
706
853
  context 'in which the video was not partnered' do
@@ -729,6 +876,16 @@ describe Yt::Video, :partner do
729
876
  end
730
877
  end
731
878
 
879
+ describe 'impressions can be grouped by range' do
880
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
881
+
882
+ specify 'with the :by option set to :range' do
883
+ impressions = video.impressions range.merge by: :range
884
+ expect(impressions.size).to be 1
885
+ expect(impressions[:total]).to be_an Integer
886
+ end
887
+ end
888
+
732
889
  describe 'impressions can be grouped by day' do
733
890
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
734
891
  let(:keys) { range.values }
@@ -746,8 +903,8 @@ describe Yt::Video, :partner do
746
903
 
747
904
  describe 'monetized playbacks can be retrieved for a specific day' do
748
905
  context 'in which the video was partnered' do
749
- let(:monetized_playbacks) { video.monetized_playbacks_on 20.days.ago}
750
- it { expect(monetized_playbacks).to be_a Float }
906
+ let(:monetized_playbacks) { video.monetized_playbacks_on ENV['YT_TEST_PARTNER_VIDEO_DATE']}
907
+ it { expect(monetized_playbacks).to be_an Integer }
751
908
  end
752
909
 
753
910
  context 'in which the video was not partnered' do
@@ -776,6 +933,16 @@ describe Yt::Video, :partner do
776
933
  end
777
934
  end
778
935
 
936
+ describe 'monetized playbacks can be grouped by range' do
937
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
938
+
939
+ specify 'with the :by option set to :range' do
940
+ monetized_playbacks = video.monetized_playbacks range.merge by: :range
941
+ expect(monetized_playbacks.size).to be 1
942
+ expect(monetized_playbacks[:total]).to be_an Integer
943
+ end
944
+ end
945
+
779
946
  describe 'monetized_playbacks can be grouped by day' do
780
947
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
781
948
  let(:keys) { range.values }
@@ -804,17 +971,27 @@ describe Yt::Video, :partner do
804
971
  end
805
972
  end
806
973
 
974
+ describe 'annotation clicks can be grouped by range' do
975
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
976
+
977
+ specify 'with the :by option set to :range' do
978
+ annotation_clicks = video.annotation_clicks range.merge by: :range
979
+ expect(annotation_clicks.size).to be 1
980
+ expect(annotation_clicks[:total]).to be_an Integer
981
+ end
982
+ end
983
+
807
984
  describe 'annotation clicks can be grouped by day' do
808
985
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
809
986
 
810
987
  specify 'without a :by option (default)' do
811
988
  annotation_clicks = video.annotation_clicks range
812
- expect(annotation_clicks.values).to all(be_instance_of Float)
989
+ expect(annotation_clicks.values).to all(be_an Integer)
813
990
  end
814
991
 
815
992
  specify 'with the :by option set to :day' do
816
993
  annotation_clicks = video.annotation_clicks range.merge by: :day
817
- expect(annotation_clicks.values).to all(be_instance_of Float)
994
+ expect(annotation_clicks.values).to all(be_an Integer)
818
995
  end
819
996
  end
820
997
 
@@ -831,6 +1008,16 @@ describe Yt::Video, :partner do
831
1008
  end
832
1009
  end
833
1010
 
1011
+ describe 'annotation click-through rate can be grouped by range' do
1012
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1013
+
1014
+ specify 'with the :by option set to :range' do
1015
+ rate = video.annotation_click_through_rate range.merge by: :range
1016
+ expect(rate.size).to be 1
1017
+ expect(rate[:total]).to be_a Float
1018
+ end
1019
+ end
1020
+
834
1021
  describe 'annotation click-through rate can be grouped by day' do
835
1022
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
836
1023
 
@@ -858,6 +1045,16 @@ describe Yt::Video, :partner do
858
1045
  end
859
1046
  end
860
1047
 
1048
+ describe 'annotation close rate can be grouped by range' do
1049
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
1050
+
1051
+ specify 'with the :by option set to :range' do
1052
+ rate = video.annotation_close_rate range.merge by: :range
1053
+ expect(rate.size).to be 1
1054
+ expect(rate[:total]).to be_a Float
1055
+ end
1056
+ end
1057
+
861
1058
  describe 'annotation close rate can be grouped by day' do
862
1059
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE'], until: Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5} }
863
1060
 
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
  require 'yt/models/channel'
3
3
 
4
4
  describe Yt::Channel, :server_app do
5
- subject(:channel) { Yt::Channel.new id: id }
5
+ subject(:channel) { Yt::Channel.new attrs }
6
6
 
7
- context 'given an existing channel' do
8
- let(:id) { 'UCxO1tY8h1AhOz0T4ENwmpow' }
7
+ context 'given an existing channel ID' do
8
+ let(:attrs) { {id: 'UCxO1tY8h1AhOz0T4ENwmpow'} }
9
9
 
10
10
  it 'returns valid snippet data' do
11
11
  expect(channel.snippet).to be_a Yt::Snippet
@@ -27,20 +27,30 @@ describe Yt::Channel, :server_app do
27
27
  end
28
28
 
29
29
  context 'with a hidden list of subscriptions' do
30
- let(:id) { 'UCG0hw7n_v0sr8MXgb6oel6w' }
30
+ let(:attrs) { {id: 'UCG0hw7n_v0sr8MXgb6oel6w'} }
31
31
  it { expect{channel.subscribed_channels.size}.to raise_error Yt::Errors::Forbidden }
32
32
  end
33
33
  end
34
34
 
35
- context 'given an unknown channel' do
36
- let(:id) { 'not-a-channel-id' }
35
+ context 'given an existing channel URL' do
36
+ let(:attrs) { {url: 'youtube.com/fullscreen'} }
37
+
38
+ specify 'provides access to its data' do
39
+ expect(channel.id).to eq 'UCxO1tY8h1AhOz0T4ENwmpow'
40
+ expect(channel.title).to eq 'Fullscreen'
41
+ expect(channel.privacy_status).to eq 'public'
42
+ end
43
+ end
44
+
45
+ context 'given an unknown channel ID' do
46
+ let(:attrs) { {id: 'not-a-channel-id'} }
37
47
 
38
48
  it { expect{channel.snippet}.to raise_error Yt::Errors::NoItems }
39
49
  it { expect{channel.status}.to raise_error Yt::Errors::NoItems }
40
50
  it { expect{channel.statistics_set}.to raise_error Yt::Errors::NoItems }
41
51
 
42
52
  describe 'starting with UC' do
43
- let(:id) { 'UC-not-a-channel-id' }
53
+ let(:attrs) { {id: 'UC-not-a-channel-id'} }
44
54
 
45
55
  # NOTE: This test is just a reflection of YouTube irrational behavior of
46
56
  # returns 0 results if the name of an unknown channel starts with UC, but
@@ -49,4 +59,14 @@ describe Yt::Channel, :server_app do
49
59
  it { expect(channel.videos.size).to be_zero }
50
60
  end
51
61
  end
62
+
63
+ context 'given an unknown channel URL' do
64
+ let(:attrs) { {url: 'youtube.com/--not-a-valid-url--'} }
65
+
66
+ specify 'accessing its data raises an error' do
67
+ expect{channel.id}.to raise_error Yt::Errors::NoItems
68
+ expect{channel.title}.to raise_error Yt::Errors::NoItems
69
+ expect{channel.status}.to raise_error Yt::Errors::NoItems
70
+ end
71
+ end
52
72
  end
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
  require 'yt/models/playlist'
3
3
 
4
4
  describe Yt::Playlist, :server_app do
5
- subject(:playlist) { Yt::Playlist.new id: id }
5
+ subject(:playlist) { Yt::Playlist.new attrs }
6
6
 
7
- context 'given an existing playlist' do
8
- let(:id) { 'PLSWYkYzOrPMT9pJG5St5G0WDalhRzGkU4' }
7
+ context 'given an existing playlist ID' do
8
+ let(:attrs) { {id: 'PLSWYkYzOrPMT9pJG5St5G0WDalhRzGkU4'} }
9
9
 
10
10
  it 'returns valid snippet data' do
11
11
  expect(playlist.snippet).to be_a Yt::Snippet
@@ -23,10 +23,31 @@ describe Yt::Playlist, :server_app do
23
23
  it { expect(playlist.playlist_items.first).to be_a Yt::PlaylistItem }
24
24
  end
25
25
 
26
+ context 'given an existing playlist URL' do
27
+ let(:attrs) { {url: 'https://www.youtube.com/playlist?list=LLxO1tY8h1AhOz0T4ENwmpow'} }
28
+
29
+ specify 'provides access to its data' do
30
+ expect(playlist.id).to eq 'LLxO1tY8h1AhOz0T4ENwmpow'
31
+ expect(playlist.title).to eq 'Liked videos'
32
+ expect(playlist.privacy_status).to eq 'public'
33
+ end
34
+ end
35
+
26
36
  context 'given an unknown playlist' do
27
- let(:id) { 'not-a-playlist-id' }
37
+ let(:attrs) { {id: 'not-a-playlist-id'} }
28
38
 
29
39
  it { expect{playlist.snippet}.to raise_error Yt::Errors::NoItems }
30
40
  it { expect{playlist.status}.to raise_error Yt::Errors::NoItems }
31
41
  end
42
+
43
+
44
+ context 'given an unknown playlist URL' do
45
+ let(:attrs) { {url: 'youtube.com/--not-a-valid-url--'} }
46
+
47
+ specify 'accessing its data raises an error' do
48
+ expect{playlist.id}.to raise_error Yt::Errors::NoItems
49
+ expect{playlist.title}.to raise_error Yt::Errors::NoItems
50
+ expect{playlist.status}.to raise_error Yt::Errors::NoItems
51
+ end
52
+ end
32
53
  end
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
  require 'yt/models/video'
3
3
 
4
4
  describe Yt::Video, :server_app do
5
- subject(:video) { Yt::Video.new id: id }
5
+ subject(:video) { Yt::Video.new attrs }
6
6
 
7
- context 'given an existing video' do
8
- let(:id) { 'MESycYJytkU' }
7
+ context 'given an existing video ID' do
8
+ let(:attrs) { {id: 'MESycYJytkU'} }
9
9
 
10
10
  it { expect(video.content_detail).to be_a Yt::ContentDetail }
11
11
 
@@ -26,12 +26,33 @@ describe Yt::Video, :server_app do
26
26
  it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
27
27
  end
28
28
 
29
- context 'given an unknown video' do
30
- let(:id) { 'not-a-video-id' }
29
+ context 'given an existing video URL' do
30
+ let(:attrs) { {url: 'https://www.youtube.com/watch?v=MESycYJytkU&list=LLxO1tY8h1AhOz0T4ENwmpow'} }
31
+
32
+ specify 'provides access to its data' do
33
+ expect(video.id).to eq 'MESycYJytkU'
34
+ expect(video.title).to eq 'Fullscreen Creator Platform'
35
+ expect(video.privacy_status).to eq 'public'
36
+ end
37
+ end
38
+
39
+ context 'given an unknown video ID' do
40
+ let(:attrs) { {id: 'not-a-video-id'} }
31
41
 
32
42
  it { expect{video.content_detail}.to raise_error Yt::Errors::NoItems }
33
43
  it { expect{video.snippet}.to raise_error Yt::Errors::NoItems }
34
44
  it { expect{video.status}.to raise_error Yt::Errors::NoItems }
35
45
  it { expect{video.statistics_set}.to raise_error Yt::Errors::NoItems }
36
46
  end
47
+
48
+ context 'given an unknown video URL' do
49
+ let(:attrs) { {url: 'youtube.com/--not-a-valid-url--'} }
50
+
51
+ specify 'accessing its data raises an error' do
52
+ expect{video.id}.to raise_error Yt::Errors::NoItems
53
+ expect{video.title}.to raise_error Yt::Errors::NoItems
54
+ expect{video.status}.to raise_error Yt::Errors::NoItems
55
+ end
56
+ end
57
+
37
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -284,7 +284,6 @@ files:
284
284
  - spec/requests/as_server_app/channel_spec.rb
285
285
  - spec/requests/as_server_app/playlist_item_spec.rb
286
286
  - spec/requests/as_server_app/playlist_spec.rb
287
- - spec/requests/as_server_app/resource_spec.rb
288
287
  - spec/requests/as_server_app/video_spec.rb
289
288
  - spec/requests/as_server_app/videos_spec.rb
290
289
  - spec/requests/unauthenticated/video_spec.rb
@@ -386,7 +385,6 @@ test_files:
386
385
  - spec/requests/as_server_app/channel_spec.rb
387
386
  - spec/requests/as_server_app/playlist_item_spec.rb
388
387
  - spec/requests/as_server_app/playlist_spec.rb
389
- - spec/requests/as_server_app/resource_spec.rb
390
388
  - spec/requests/as_server_app/video_spec.rb
391
389
  - spec/requests/as_server_app/videos_spec.rb
392
390
  - spec/requests/unauthenticated/video_spec.rb
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/resource'
3
-
4
- describe Yt::Resource, :server_app do
5
- subject(:resource) { Yt::Resource.new url: url }
6
-
7
- context 'given the URL of an existing channel' do
8
- let(:url) { 'youtube.com/fullscreen' }
9
-
10
- specify 'provides access to its data' do
11
- expect(resource.id).to eq 'UCxO1tY8h1AhOz0T4ENwmpow'
12
- expect(resource.title).to eq 'Fullscreen'
13
- expect(resource.privacy_status).to eq 'public'
14
- end
15
- end
16
-
17
- context 'given the URL of an existing video' do
18
- let(:url) { 'https://www.youtube.com/watch?v=MESycYJytkU&list=LLxO1tY8h1AhOz0T4ENwmpow' }
19
-
20
- specify 'provides access to its data' do
21
- expect(resource.id).to eq 'MESycYJytkU'
22
- expect(resource.title).to eq 'Fullscreen Creator Platform'
23
- expect(resource.privacy_status).to eq 'public'
24
- end
25
- end
26
-
27
- context 'given the URL of an existing playlist' do
28
- let(:url) { 'https://www.youtube.com/playlist?list=LLxO1tY8h1AhOz0T4ENwmpow' }
29
-
30
- specify 'provides access to its data' do
31
- expect(resource.id).to eq 'LLxO1tY8h1AhOz0T4ENwmpow'
32
- expect(resource.title).to eq 'Liked videos'
33
- expect(resource.privacy_status).to eq 'public'
34
- end
35
- end
36
-
37
- context 'given an unknown URL' do
38
- let(:url) { 'youtube.com/--not-a-valid-url--' }
39
-
40
- specify 'accessing its data raises an error' do
41
- expect{resource.id}.to raise_error Yt::Errors::NoItems
42
- expect{resource.title}.to raise_error Yt::Errors::NoItems
43
- expect{resource.status}.to raise_error Yt::Errors::NoItems
44
- end
45
- end
46
- end