yt 0.32.6 → 0.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -4
  3. data/CHANGELOG.md +19 -0
  4. data/README.md +22 -32
  5. data/YOUTUBE_IT.md +4 -4
  6. data/lib/yt.rb +0 -1
  7. data/lib/yt/associations/has_reports.rb +9 -14
  8. data/lib/yt/collections/reports.rb +5 -7
  9. data/lib/yt/models/resource.rb +69 -3
  10. data/lib/yt/models/url.rb +2 -60
  11. data/lib/yt/request.rb +6 -2
  12. data/lib/yt/version.rb +1 -1
  13. data/yt.gemspec +5 -2
  14. metadata +31 -169
  15. data/spec/collections/claims_spec.rb +0 -62
  16. data/spec/collections/comment_threads_spec.rb +0 -46
  17. data/spec/collections/playlist_items_spec.rb +0 -44
  18. data/spec/collections/playlists_spec.rb +0 -27
  19. data/spec/collections/policies_spec.rb +0 -30
  20. data/spec/collections/references_spec.rb +0 -30
  21. data/spec/collections/reports_spec.rb +0 -30
  22. data/spec/collections/subscriptions_spec.rb +0 -25
  23. data/spec/collections/videos_spec.rb +0 -43
  24. data/spec/constants/geography_spec.rb +0 -16
  25. data/spec/errors/forbidden_spec.rb +0 -10
  26. data/spec/errors/missing_auth_spec.rb +0 -24
  27. data/spec/errors/no_items_spec.rb +0 -10
  28. data/spec/errors/request_error_spec.rb +0 -44
  29. data/spec/errors/server_error_spec.rb +0 -10
  30. data/spec/errors/unauthorized_spec.rb +0 -10
  31. data/spec/models/account_spec.rb +0 -138
  32. data/spec/models/annotation_spec.rb +0 -180
  33. data/spec/models/asset_spec.rb +0 -32
  34. data/spec/models/channel_spec.rb +0 -127
  35. data/spec/models/claim_event_spec.rb +0 -62
  36. data/spec/models/claim_history_spec.rb +0 -27
  37. data/spec/models/claim_spec.rb +0 -223
  38. data/spec/models/comment_spec.rb +0 -40
  39. data/spec/models/comment_thread_spec.rb +0 -93
  40. data/spec/models/configuration_spec.rb +0 -44
  41. data/spec/models/content_detail_spec.rb +0 -52
  42. data/spec/models/content_owner_detail_spec.rb +0 -6
  43. data/spec/models/file_detail_spec.rb +0 -13
  44. data/spec/models/live_streaming_detail_spec.rb +0 -6
  45. data/spec/models/ownership_spec.rb +0 -59
  46. data/spec/models/player_spec.rb +0 -13
  47. data/spec/models/playlist_item_spec.rb +0 -120
  48. data/spec/models/playlist_spec.rb +0 -138
  49. data/spec/models/policy_rule_spec.rb +0 -63
  50. data/spec/models/policy_spec.rb +0 -41
  51. data/spec/models/rating_spec.rb +0 -12
  52. data/spec/models/reference_spec.rb +0 -249
  53. data/spec/models/request_spec.rb +0 -204
  54. data/spec/models/resource_spec.rb +0 -42
  55. data/spec/models/right_owner_spec.rb +0 -71
  56. data/spec/models/snippet_spec.rb +0 -13
  57. data/spec/models/statistics_set_spec.rb +0 -13
  58. data/spec/models/status_spec.rb +0 -13
  59. data/spec/models/subscription_spec.rb +0 -30
  60. data/spec/models/url_spec.rb +0 -78
  61. data/spec/models/video_category_spec.rb +0 -21
  62. data/spec/models/video_spec.rb +0 -669
  63. data/spec/requests/as_account/account_spec.rb +0 -143
  64. data/spec/requests/as_account/authentications_spec.rb +0 -127
  65. data/spec/requests/as_account/channel_spec.rb +0 -246
  66. data/spec/requests/as_account/channels_spec.rb +0 -18
  67. data/spec/requests/as_account/playlist_item_spec.rb +0 -55
  68. data/spec/requests/as_account/playlist_spec.rb +0 -218
  69. data/spec/requests/as_account/thumbnail.jpg +0 -0
  70. data/spec/requests/as_account/video.mp4 +0 -0
  71. data/spec/requests/as_account/video_spec.rb +0 -408
  72. data/spec/requests/as_content_owner/account_spec.rb +0 -29
  73. data/spec/requests/as_content_owner/advertising_options_set_spec.rb +0 -15
  74. data/spec/requests/as_content_owner/asset_spec.rb +0 -31
  75. data/spec/requests/as_content_owner/bulk_report_job_spec.rb +0 -19
  76. data/spec/requests/as_content_owner/channel_spec.rb +0 -1836
  77. data/spec/requests/as_content_owner/claim_history_spec.rb +0 -20
  78. data/spec/requests/as_content_owner/claim_spec.rb +0 -17
  79. data/spec/requests/as_content_owner/content_owner_spec.rb +0 -370
  80. data/spec/requests/as_content_owner/match_policy_spec.rb +0 -17
  81. data/spec/requests/as_content_owner/ownership_spec.rb +0 -25
  82. data/spec/requests/as_content_owner/playlist_spec.rb +0 -767
  83. data/spec/requests/as_content_owner/video_group_spec.rb +0 -112
  84. data/spec/requests/as_content_owner/video_spec.rb +0 -1223
  85. data/spec/requests/as_server_app/channel_spec.rb +0 -54
  86. data/spec/requests/as_server_app/comment_spec.rb +0 -22
  87. data/spec/requests/as_server_app/comment_thread_spec.rb +0 -27
  88. data/spec/requests/as_server_app/comment_threads_spec.rb +0 -41
  89. data/spec/requests/as_server_app/playlist_item_spec.rb +0 -30
  90. data/spec/requests/as_server_app/playlist_spec.rb +0 -33
  91. data/spec/requests/as_server_app/url_spec.rb +0 -94
  92. data/spec/requests/as_server_app/video_spec.rb +0 -60
  93. data/spec/requests/as_server_app/videos_spec.rb +0 -40
  94. data/spec/requests/unauthenticated/video_spec.rb +0 -14
  95. data/spec/spec_helper.rb +0 -20
  96. data/spec/support/fail_matcher.rb +0 -15
  97. data/spec/support/global_hooks.rb +0 -48
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/video_category'
3
-
4
- describe Yt::VideoCategory do
5
- subject(:video_category) { Yt::VideoCategory.new attrs }
6
-
7
- describe '#id' do
8
- context 'given fetching a video category returns an id' do
9
- let(:attrs) { {id: "22"} }
10
- it { expect(video_category.id).to eq '22' }
11
- end
12
- end
13
-
14
- describe '#snippet' do
15
- context 'given fetching a video category returns a snippet' do
16
- let(:attrs) { {snippet: {"title": "People & Blogs", "assignable": true}} }
17
-
18
- it { expect(video_category.snippet).to be_a Yt::Snippet }
19
- end
20
- end
21
- end
@@ -1,669 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/video'
3
-
4
- describe Yt::Video do
5
- subject(:video) { Yt::Video.new attrs }
6
-
7
- describe '#snippet' do
8
- context 'given fetching a video returns a snippet' do
9
- let(:attrs) { {snippet: {"title"=>"Fullscreen Creator Platform"}} }
10
- it { expect(video.snippet).to be_a Yt::Snippet }
11
- end
12
- end
13
-
14
-
15
- describe '#title' do
16
- context 'given a snippet with a title' do
17
- let(:attrs) { {snippet: {"title"=>"Fullscreen Creator Platform"}} }
18
- it { expect(video.title).to eq 'Fullscreen Creator Platform' }
19
- end
20
-
21
- context 'given a snippet without a title' do
22
- let(:attrs) { {snippet: {}} }
23
- it { expect(video.title).to eq '' }
24
- end
25
- end
26
-
27
- describe '#description' do
28
- context 'given a snippet with a description' do
29
- let(:attrs) { {snippet: {"description"=>"A cool video."}} }
30
- it { expect(video.description).to eq 'A cool video.' }
31
- end
32
-
33
- context 'given a snippet without a description' do
34
- let(:attrs) { {snippet: {}} }
35
- it { expect(video.description).to eq '' }
36
- end
37
- end
38
-
39
- describe '#thumbnail_url' do
40
- context 'given a snippet with thumbnails' do
41
- let(:attrs) { {snippet: {"thumbnails"=>{
42
- "default"=>{"url"=> "http://example.com/120x90.jpg"},
43
- "medium"=>{"url"=> "http://example.com/320x180.jpg"},
44
- }}} }
45
- it { expect(video.thumbnail_url).to eq 'http://example.com/120x90.jpg' }
46
- it { expect(video.thumbnail_url 'default').to eq 'http://example.com/120x90.jpg' }
47
- it { expect(video.thumbnail_url :default).to eq 'http://example.com/120x90.jpg' }
48
- it { expect(video.thumbnail_url :medium).to eq 'http://example.com/320x180.jpg' }
49
- it { expect(video.thumbnail_url :high).to be_nil }
50
- end
51
-
52
- context 'given a snippet without thumbnails' do
53
- let(:attrs) { {snippet: {}} }
54
- it { expect(video.thumbnail_url).to be_nil }
55
- end
56
- end
57
-
58
- describe '#published_at' do
59
- context 'given a snippet with a timestamp' do
60
- let(:attrs) { {snippet: {"publishedAt"=>"2014-04-22T19:14:49.000Z"}} }
61
- it { expect(video.published_at.year).to be 2014 }
62
- end
63
- end
64
-
65
- describe '#channel_id' do
66
- context 'given a snippet with a channel ID' do
67
- let(:attrs) { {snippet: {"channelId"=>"UCxO1tY8h1AhOz0T4ENwmpow"}} }
68
- it { expect(video.channel_id).to eq 'UCxO1tY8h1AhOz0T4ENwmpow' }
69
- end
70
-
71
- context 'given a snippet without a channel ID' do
72
- let(:attrs) { {snippet: {}} }
73
- it { expect(video.channel_id).to be_nil }
74
- end
75
- end
76
-
77
- describe '#channel_title' do
78
- context 'given a snippet with a channel title' do
79
- let(:attrs) { {snippet: {"channelTitle"=>"Fullscreen"}} }
80
- it { expect(video.channel_title).to eq 'Fullscreen' }
81
- end
82
-
83
- context 'given a snippet without a channel title' do
84
- let(:attrs) { {snippet: {}} }
85
- it { expect(video.channel_title).to be_nil }
86
- end
87
- end
88
-
89
- describe '#live_broadcast_content' do
90
- context 'given a snippet with live broadcast content' do
91
- let(:attrs) { {snippet: {"liveBroadcastContent"=>"live"}} }
92
- it { expect(video.live_broadcast_content).to eq 'live' }
93
- end
94
-
95
- context 'given a snippet without live broadcast content' do
96
- let(:attrs) { {snippet: {}} }
97
- it { expect(video.live_broadcast_content).to be_nil }
98
- end
99
- end
100
-
101
- describe '#tags' do
102
- context 'given a snippet with tags' do
103
- let(:attrs) { {snippet: {"tags"=>["promotion", "new media"]}} }
104
- it { expect(video.tags).to eq ["promotion", "new media"] }
105
- end
106
-
107
- context 'given a snippet without tags' do
108
- let(:attrs) { {snippet: {}} }
109
- it { expect(video.tags).to eq [] }
110
- end
111
- end
112
-
113
- describe '#category_id' do
114
- context 'given a snippet with a category ID' do
115
- let(:attrs) { {snippet: {"categoryId"=>"22"}} }
116
- it { expect(video.category_id).to eq '22' }
117
- end
118
-
119
- context 'given a snippet without a category ID' do
120
- let(:attrs) { {snippet: {}} }
121
- it { expect(video.category_id).to be_nil }
122
- end
123
- end
124
-
125
-
126
- describe '#deleted?' do
127
- context 'given fetching a status returns uploadStatus "deleted"' do
128
- let(:attrs) { {status: {"uploadStatus"=>"deleted"}} }
129
- it { expect(video).to be_deleted }
130
- end
131
-
132
- context 'given fetching a status does not return uploadStatus "deleted"' do
133
- let(:attrs) { {status: {"uploadStatus"=>"uploaded"}} }
134
- it { expect(video).not_to be_deleted }
135
- end
136
- end
137
-
138
- describe '#failed?' do
139
- context 'given fetching a status returns uploadStatus "failed"' do
140
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
141
- it { expect(video).to be_failed }
142
- end
143
-
144
- context 'given fetching a status does not return uploadStatus "failed"' do
145
- let(:attrs) { {status: {"uploadStatus"=>"uploaded"}} }
146
- it { expect(video).not_to be_failed }
147
- end
148
- end
149
-
150
- describe '#processed?' do
151
- context 'given fetching a status returns uploadStatus "processed"' do
152
- let(:attrs) { {status: {"uploadStatus"=>"processed"}} }
153
- it { expect(video).to be_processed }
154
- end
155
-
156
- context 'given fetching a status does not return uploadStatus "processed"' do
157
- let(:attrs) { {status: {"uploadStatus"=>"uploaded"}} }
158
- it { expect(video).not_to be_processed }
159
- end
160
- end
161
-
162
- describe '#rejected?' do
163
- context 'given fetching a status returns uploadStatus "rejected"' do
164
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
165
- it { expect(video).to be_rejected }
166
- end
167
-
168
- context 'given fetching a status does not return uploadStatus "rejected"' do
169
- let(:attrs) { {status: {"uploadStatus"=>"uploaded"}} }
170
- it { expect(video).not_to be_rejected }
171
- end
172
- end
173
-
174
- describe '#uploading?' do
175
- context 'given fetching a status returns uploadStatus "uploaded"' do
176
- let(:attrs) { {status: {"uploadStatus"=>"uploaded"}} }
177
- it { expect(video).to be_uploading }
178
- end
179
-
180
- context 'given fetching a status does not return uploadStatus "uploaded"' do
181
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
182
- it { expect(video).not_to be_uploading }
183
- end
184
- end
185
-
186
- describe '#uses_unsupported_codec?' do
187
- context 'given fetching a status returns failureReason "codec"' do
188
- let(:attrs) { {status: {"uploadStatus"=>"failed", "failureReason"=>"codec"}} }
189
- it { expect(video.uses_unsupported_codec?).to be true }
190
- end
191
-
192
- context 'given fetching a status does not return failureReason "codec"' do
193
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
194
- it { expect(video.uses_unsupported_codec?).to be false }
195
- end
196
- end
197
-
198
- describe '#conversion_failed?' do
199
- context 'given fetching a status returns failureReason "conversion"' do
200
- let(:attrs) { {status: {"uploadStatus"=>"failed", "failureReason"=>"conversion"}} }
201
- it { expect(video).to have_failed_conversion }
202
- end
203
-
204
- context 'given fetching a status does not return failureReason "conversion"' do
205
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
206
- it { expect(video).not_to have_failed_conversion }
207
- end
208
- end
209
-
210
- describe '#empty_file?' do
211
- context 'given fetching a status returns failureReason "emptyFile"' do
212
- let(:attrs) { {status: {"uploadStatus"=>"failed", "failureReason"=>"emptyFile"}} }
213
- it { expect(video).to be_empty }
214
- end
215
-
216
- context 'given fetching a status does not return failureReason "emptyFile"' do
217
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
218
- it { expect(video).not_to be_empty }
219
- end
220
- end
221
-
222
- describe '#invalid_file?' do
223
- context 'given fetching a status returns failureReason "invalidFile"' do
224
- let(:attrs) { {status: {"uploadStatus"=>"failed", "failureReason"=>"invalidFile"}} }
225
- it { expect(video).to be_invalid }
226
- end
227
-
228
- context 'given fetching a status does not return failureReason "invalidFile"' do
229
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
230
- it { expect(video).not_to be_invalid }
231
- end
232
- end
233
-
234
- describe '#too_small?' do
235
- context 'given fetching a status returns failureReason "tooSmall"' do
236
- let(:attrs) { {status: {"uploadStatus"=>"failed", "failureReason"=>"tooSmall"}} }
237
- it { expect(video).to be_too_small }
238
- end
239
-
240
- context 'given fetching a status does not return failureReason "tooSmall"' do
241
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
242
- it { expect(video).not_to be_too_small }
243
- end
244
- end
245
-
246
- describe '#upload_aborted?' do
247
- context 'given fetching a status returns failureReason "uploadAborted"' do
248
- let(:attrs) { {status: {"uploadStatus"=>"failed", "failureReason"=>"uploadAborted"}} }
249
- it { expect(video).to be_aborted }
250
- end
251
-
252
- context 'given fetching a status does not return failureReason "uploadAborted"' do
253
- let(:attrs) { {status: {"uploadStatus"=>"failed"}} }
254
- it { expect(video).not_to be_aborted }
255
- end
256
- end
257
-
258
- describe '#claimed?' do
259
- context 'given fetching a status returns rejectionReason "claim"' do
260
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"claim"}} }
261
- it { expect(video).to be_claimed }
262
- end
263
-
264
- context 'given fetching a status does not return rejectionReason "claim"' do
265
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
266
- it { expect(video).not_to be_claimed }
267
- end
268
- end
269
-
270
- describe '#infringes_copyright?' do
271
- context 'given fetching a status returns rejectionReason "copyright"' do
272
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"copyright"}} }
273
- it { expect(video.infringes_copyright?).to be true }
274
- end
275
-
276
- context 'given fetching a status does not return rejectionReason "copyright"' do
277
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
278
- it { expect(video.infringes_copyright?).to be false }
279
- end
280
- end
281
-
282
- describe '#duplicate?' do
283
- context 'given fetching a status returns rejectionReason "duplicate"' do
284
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"duplicate"}} }
285
- it { expect(video).to be_duplicate }
286
- end
287
-
288
- context 'given fetching a status does not return rejectionReason "duplicate"' do
289
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
290
- it { expect(video).not_to be_duplicate }
291
- end
292
- end
293
-
294
- describe '#inappropriate?' do
295
- context 'given fetching a status returns rejectionReason "inappropriate"' do
296
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"inappropriate"}} }
297
- it { expect(video).to be_inappropriate }
298
- end
299
-
300
- context 'given fetching a status does not return rejectionReason "inappropriate"' do
301
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
302
- it { expect(video).not_to be_inappropriate }
303
- end
304
- end
305
-
306
- describe '#too_long?' do
307
- context 'given fetching a status returns rejectionReason "length"' do
308
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"length"}} }
309
- it { expect(video).to be_too_long }
310
- end
311
-
312
- context 'given fetching a status does not return rejectionReason "length"' do
313
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
314
- it { expect(video).not_to be_too_long }
315
- end
316
- end
317
-
318
- describe '#violates_terms_of_use?' do
319
- context 'given fetching a status returns rejectionReason "termsOfUse"' do
320
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"termsOfUse"}} }
321
- it { expect(video.violates_terms_of_use?).to be true }
322
- end
323
-
324
- context 'given fetching a status does not return rejectionReason "termsOfUse"' do
325
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
326
- it { expect(video.violates_terms_of_use?).to be false }
327
- end
328
- end
329
-
330
- describe '#infringes_trademark?' do
331
- context 'given fetching a status returns rejectionReason "trademark"' do
332
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"trademark"}} }
333
- it { expect(video.infringes_trademark?).to be true }
334
- end
335
-
336
- context 'given fetching a status does not return rejectionReason "trademark"' do
337
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
338
- it { expect(video.infringes_trademark?).to be false }
339
- end
340
- end
341
-
342
- describe '#belongs_to_closed_account?' do
343
- context 'given fetching a status returns rejectionReason "uploaderAccountClosed"' do
344
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"uploaderAccountClosed"}} }
345
- it { expect(video.belongs_to_closed_account?).to be true }
346
- end
347
-
348
- context 'given fetching a status does not return rejectionReason "uploaderAccountClosed"' do
349
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
350
- it { expect(video.belongs_to_closed_account?).to be false }
351
- end
352
- end
353
-
354
- describe '#belongs_to_suspended_account?' do
355
- context 'given fetching a status returns rejectionReason "uploaderAccountSuspended"' do
356
- let(:attrs) { {status: {"uploadStatus"=>"rejected", "rejectionReason"=>"uploaderAccountSuspended"}} }
357
- it { expect(video.belongs_to_suspended_account?).to be true }
358
- end
359
-
360
- context 'given fetching a status does not return rejectionReason "uploaderAccountSuspended"' do
361
- let(:attrs) { {status: {"uploadStatus"=>"rejected"}} }
362
- it { expect(video.belongs_to_suspended_account?).to be false }
363
- end
364
- end
365
-
366
- describe '#scheduled_at and #scheduled' do
367
- context 'given fetching a status returns "publishAt"' do
368
- let(:attrs) { {status: {"uploadStatus"=>"uploaded", "privacyStatus"=>"private", "publishAt"=>"2014-04-22T19:14:49.000Z"}} }
369
- it { expect(video).to be_scheduled }
370
- it { expect(video.scheduled_at.year).to be 2014 }
371
- end
372
-
373
- context 'given fetching a status does not returns "publishAt"' do
374
- let(:attrs) { {status: {"uploadStatus"=>"uploaded", "privacyStatus"=>"private"}} }
375
- it { expect(video).not_to be_scheduled }
376
- it { expect(video.scheduled_at).not_to be }
377
- end
378
- end
379
-
380
- describe '#licensed_as_creative_commons?' do
381
- context 'given fetching a status returns license "creativeCommon"' do
382
- let(:attrs) { {status: {"uploadStatus"=>"uploaded", "license"=>"creativeCommon"}} }
383
- it { expect(video).to be_licensed_as_creative_commons }
384
- end
385
-
386
- context 'given fetching a status does not return license "creativeCommon"' do
387
- let(:attrs) { {status: {"uploadStatus"=>"uploaded"}} }
388
- it { expect(video).not_to be_licensed_as_creative_commons }
389
- end
390
- end
391
-
392
- describe '#licensed_as_standard_youtube?' do
393
- context 'given fetching a status returns license "youtube"' do
394
- let(:attrs) { {status: {"uploadStatus"=>"uploaded", "license"=>"youtube"}} }
395
- it { expect(video).to be_licensed_as_standard_youtube }
396
- end
397
-
398
- context 'given fetching a status does not return license "youtube"' do
399
- let(:attrs) { {status: {"uploadStatus"=>"uploaded"}} }
400
- it { expect(video).not_to be_licensed_as_standard_youtube }
401
- end
402
- end
403
-
404
- describe '#embeddable?' do
405
- context 'given fetching a status returns "embeddable" true' do
406
- let(:attrs) { {status: {"uploadStatus"=>"uploaded", "embeddable"=>true}} }
407
- it { expect(video).to be_embeddable }
408
- end
409
-
410
- context 'given fetching a status returns "embeddable" false' do
411
- let(:attrs) { {status: {"uploadStatus"=>"uploaded", "embeddable"=>false}} }
412
- it { expect(video).not_to be_embeddable }
413
- end
414
- end
415
-
416
- describe '#has_public_stats_viewable?' do
417
- context 'given fetching a status returns "publicStatsViewable" true' do
418
- let(:attrs) { {status: {"publicStatsViewable"=>true}} }
419
- it { expect(video).to have_public_stats_viewable }
420
- end
421
-
422
- context 'given fetching a status returns "publicStatsViewable" false' do
423
- let(:attrs) { {status: {"publicStatsViewable"=>false}} }
424
- it { expect(video).not_to have_public_stats_viewable }
425
- end
426
- end
427
-
428
- describe '#stereoscopic?' do
429
- context 'given a 3D video' do
430
- let(:attrs) { {content_details: {"dimension"=>"3d"}} }
431
- it { expect(video).to be_stereoscopic }
432
- end
433
-
434
- context 'given a 2D video' do
435
- let(:attrs) { {content_details: {"dimension"=>"2d"}} }
436
- it { expect(video).not_to be_stereoscopic }
437
- end
438
- end
439
-
440
- describe '#hd?' do
441
- context 'given a high-definition video' do
442
- let(:attrs) { {content_details: {"definition"=>"hd"}} }
443
- it { expect(video).to be_hd }
444
- end
445
-
446
- context 'given a standard-definition video' do
447
- let(:attrs) { {content_details: {"definition"=>"sd"}} }
448
- it { expect(video).not_to be_hd }
449
- end
450
- end
451
-
452
- describe '#captioned?' do
453
- context 'given a video with captions' do
454
- let(:attrs) { {content_details: {"caption"=>"true"}} }
455
- it { expect(video).to be_captioned }
456
- end
457
-
458
- context 'given a video without captions' do
459
- let(:attrs) { {content_details: {"caption"=>"false"}} }
460
- it { expect(video).not_to be_captioned }
461
- end
462
- end
463
-
464
- describe '#licensed?' do
465
- context 'given a video with licensed content' do
466
- let(:attrs) { {content_details: {"licensedContent"=>true}} }
467
- it { expect(video).to be_licensed }
468
- end
469
-
470
- context 'given a video without licensed content' do
471
- let(:attrs) { {content_details: {"licensedContent"=>false}} }
472
- it { expect(video).not_to be_licensed }
473
- end
474
- end
475
-
476
- describe '#age_restricted?' do
477
- context 'given a video with age restricted content' do
478
- let(:attrs) { {content_details: {"contentRating"=>{"ytRating"=>"ytAgeRestricted"}}} }
479
- it { expect(video).to be_age_restricted }
480
- end
481
-
482
- context 'given a video without age restricted content' do
483
- let(:attrs) { {content_details: {}} }
484
- it { expect(video).not_to be_age_restricted }
485
- end
486
-
487
- context 'given a video with a content rating but not ytRating' do
488
- let(:attrs) { {content_details: {"contentRating"=>{"acbRating": "PG"}}} }
489
- it { expect(video).not_to be_age_restricted }
490
- end
491
- end
492
-
493
- describe '#file_size' do
494
- context 'given a video with fileSize' do
495
- let(:attrs) { {file_details: {"fileSize"=>"8000000"}} }
496
- it { expect(video.file_size).to be 8_000_000 }
497
- end
498
- end
499
-
500
- describe '#file_type' do
501
- context 'given a video with fileType' do
502
- let(:attrs) { {file_details: {"fileType"=>"video"}} }
503
- it { expect(video.file_type).to eq 'video' }
504
- end
505
- end
506
-
507
- describe '#container' do
508
- context 'given a video with container' do
509
- let(:attrs) { {file_details: {"container"=>"mov"}} }
510
- it { expect(video.container).to eq 'mov' }
511
- end
512
- end
513
-
514
- describe '#actual_start_time' do
515
- context 'given a non-live streaming video' do
516
- let(:attrs) { {live_streaming_details: {}} }
517
- it { expect(video.actual_start_time).to be_nil }
518
- end
519
-
520
- context 'given a live streaming video that has not started yet' do
521
- let(:attrs) { {live_streaming_details: {"scheduledStartTime"=>"2017-07-10T00:00:00.000Z"}} }
522
- it { expect(video.actual_start_time).to be_nil }
523
- end
524
-
525
- context 'given a live streaming video that has started' do
526
- let(:attrs) { {live_streaming_details: {"actualStartTime"=>"2014-08-01T17:48:40.678Z"}} }
527
- it { expect(video.actual_start_time.year).to be 2014 }
528
- end
529
- end
530
-
531
- describe '#actual_end_time' do
532
- context 'given a non-live streaming video' do
533
- let(:attrs) { {live_streaming_details: {}} }
534
- it { expect(video.actual_end_time).to be_nil }
535
- end
536
-
537
- context 'given a live streaming video that has not ended yet' do
538
- let(:attrs) { {live_streaming_details: {"scheduledStartTime"=>"2017-07-10T00:00:00.000Z"}} }
539
- it { expect(video.actual_end_time).to be_nil }
540
- end
541
-
542
- context 'given a live streaming video that has ended' do
543
- let(:attrs) { {live_streaming_details: {"actualEndTime"=>"2014-08-01T17:48:40.678Z"}} }
544
- it { expect(video.actual_end_time.year).to be 2014 }
545
- end
546
- end
547
-
548
- describe '#scheduled_start_time' do
549
- context 'given a non-live streaming video' do
550
- let(:attrs) { {live_streaming_details: {}} }
551
- it { expect(video.scheduled_start_time).to be_nil }
552
- end
553
-
554
- context 'given a live streaming video' do
555
- let(:attrs) { {live_streaming_details: {"scheduledStartTime"=>"2017-07-10T00:00:00.000Z"}} }
556
- it { expect(video.scheduled_start_time.year).to be 2017 }
557
- end
558
- end
559
-
560
- describe '#scheduled_end_time' do
561
- context 'given a non-live streaming video' do
562
- let(:attrs) { {live_streaming_details: {}} }
563
- it { expect(video.scheduled_end_time).to be_nil }
564
- end
565
-
566
- context 'given a live streaming video that broadcasts indefinitely' do
567
- let(:attrs) { {live_streaming_details: {"scheduledStartTime"=>"2017-07-10T00:00:00.000Z"}} }
568
- it { expect(video.scheduled_end_time).to be_nil }
569
- end
570
-
571
- context 'given a live streaming video with a scheduled ednd' do
572
- let(:attrs) { {live_streaming_details: {"scheduledEndTime"=>"2014-08-01T17:48:40.678Z"}} }
573
- it { expect(video.scheduled_end_time.year).to be 2014 }
574
- end
575
- end
576
-
577
- describe '#concurrent_viewers' do
578
- context 'given a non-live streaming video' do
579
- let(:attrs) { {live_streaming_details: {}} }
580
- it { expect(video.concurrent_viewers).to be_nil }
581
- end
582
-
583
- context 'given a current live streaming video with viewers' do
584
- let(:attrs) { {live_streaming_details: {"concurrentViewers"=>"1"}} }
585
- it { expect(video.concurrent_viewers).to be 1 }
586
- end
587
-
588
- context 'given a past live streaming video' do
589
- let(:attrs) { {live_streaming_details: {"actualEndTime"=>"2013-08-01T17:48:40.678Z"}} }
590
- it { expect(video.concurrent_viewers).to be_nil }
591
- end
592
- end
593
-
594
- describe '#view_count' do
595
- context 'given a video with views' do
596
- let(:attrs) { {statistics: { "viewCount"=>"123"}} }
597
- it { expect(video.view_count).to be 123 }
598
- end
599
- end
600
-
601
- describe '#comment_count' do
602
- context 'given a video with comments' do
603
- let(:attrs) { {statistics: { "commentCount"=>"45"}} }
604
- it { expect(video.comment_count).to be 45 }
605
- end
606
- end
607
-
608
- describe '#like_count' do
609
- context 'given a video with likes' do
610
- let(:attrs) { {statistics: { "likeCount"=>"6"}} }
611
- it { expect(video.like_count).to be 6 }
612
- end
613
- end
614
-
615
- describe '#dislike_count' do
616
- context 'given a video with dislikes' do
617
- let(:attrs) { {statistics: { "dislikeCount"=>"9"}} }
618
- it { expect(video.dislike_count).to be 9 }
619
- end
620
- end
621
-
622
- describe '#favorite_count' do
623
- context 'given a video with favorites' do
624
- let(:attrs) { {statistics: { "favoriteCount"=>"44"}} }
625
- it { expect(video.favorite_count).to be 44 }
626
- end
627
- end
628
-
629
- describe '#embed_html' do
630
- context 'given a video with embedHtml' do
631
- let(:html) { "<iframe type='text/html' src='http://www.youtube.com/embed/BPNYv0vd78A' width='640' height='360' frameborder='0' allowfullscreen='true'/>" }
632
- let(:attrs) { {player: {"embedHtml"=>html}} }
633
- it { expect(video.embed_html).to be html }
634
- end
635
- end
636
-
637
- describe '#statistics_set' do
638
- context 'given fetching a video returns statistics' do
639
- let(:attrs) { {statistics: {"viewCount"=>"202"}} }
640
- it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
641
- end
642
- end
643
-
644
- describe '#content_details' do
645
- context 'given fetching a video returns content details' do
646
- let(:attrs) { {content_details: {"definition"=>"hd"}} }
647
- it { expect(video.content_detail).to be_a Yt::ContentDetail }
648
- end
649
- end
650
-
651
- describe '#update' do
652
- let(:attrs) { {id: '9bZkp7q19f0', snippet: {'title'=>'old'}} }
653
- before { expect(video).to receive(:do_update).and_yield 'snippet'=>{'title'=>'new'} }
654
-
655
- it { expect(video.update title: 'new').to be true }
656
- it { expect{video.update title: 'new'}.to change{video.title} }
657
- end
658
-
659
- describe '#delete' do
660
- let(:attrs) { {id: 'video-id'} }
661
-
662
- context 'given an existing video' do
663
- before { expect(video).to receive(:do_delete).and_yield }
664
-
665
- it { expect(video.delete).to be true }
666
- it { expect{video.delete}.to change{video.exists?} }
667
- end
668
- end
669
- end