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
@@ -196,7 +196,7 @@ module Yt
196
196
  # - when the user has reached the quota for requests/second, and waiting
197
197
  # for a couple of seconds might solve the connection issues.
198
198
  def run_again?
199
- refresh_token_and_retry? ||
199
+ refresh_token_and_retry? && sleep_and_retry?(3) ||
200
200
  server_error? && sleep_and_retry?(3) ||
201
201
  exceeded_quota? && sleep_and_retry?(3)
202
202
  end
@@ -234,10 +234,14 @@ module Yt
234
234
  @retries_so_far += 1
235
235
  if (@retries_so_far < max_retries)
236
236
  @response = @http_request = @uri = nil
237
- sleep 3 + (10 * @retries_so_far)
237
+ sleep retry_time
238
238
  end
239
239
  end
240
240
 
241
+ def retry_time
242
+ 3 + (10 * @retries_so_far)
243
+ end
244
+
241
245
  # In case an authorized request responds with "Unauthorized", checks
242
246
  # if the original access token can be refreshed. If that's the case,
243
247
  # clears the memoized variables and returns true, so the request can
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.32.6'
2
+ VERSION = '0.33.0'
3
3
  end
data/yt.gemspec CHANGED
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'yt/version'
@@ -16,7 +15,9 @@ Gem::Specification.new do |spec|
16
15
 
17
16
  spec.required_ruby_version = '>= 1.9.3'
18
17
 
19
- spec.files = `git ls-files`.split($/)
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
20
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
23
  spec.require_paths = ["lib"]
@@ -30,4 +31,6 @@ Gem::Specification.new do |spec|
30
31
  spec.add_development_dependency 'yard' #, '~> 0.8.0'
31
32
  spec.add_development_dependency 'coveralls' #, '~> 0.7.0'
32
33
  spec.add_development_dependency 'pry'
34
+ spec.add_development_dependency 'vcr'
35
+ spec.add_development_dependency 'webmock'
33
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.6
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-07 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description: Youtube V3 API client.
112
140
  email:
113
141
  - claudio@fullscreen.net
@@ -246,89 +274,6 @@ files:
246
274
  - lib/yt/models/video_group.rb
247
275
  - lib/yt/request.rb
248
276
  - lib/yt/version.rb
249
- - spec/collections/claims_spec.rb
250
- - spec/collections/comment_threads_spec.rb
251
- - spec/collections/playlist_items_spec.rb
252
- - spec/collections/playlists_spec.rb
253
- - spec/collections/policies_spec.rb
254
- - spec/collections/references_spec.rb
255
- - spec/collections/reports_spec.rb
256
- - spec/collections/subscriptions_spec.rb
257
- - spec/collections/videos_spec.rb
258
- - spec/constants/geography_spec.rb
259
- - spec/errors/forbidden_spec.rb
260
- - spec/errors/missing_auth_spec.rb
261
- - spec/errors/no_items_spec.rb
262
- - spec/errors/request_error_spec.rb
263
- - spec/errors/server_error_spec.rb
264
- - spec/errors/unauthorized_spec.rb
265
- - spec/models/account_spec.rb
266
- - spec/models/annotation_spec.rb
267
- - spec/models/asset_spec.rb
268
- - spec/models/channel_spec.rb
269
- - spec/models/claim_event_spec.rb
270
- - spec/models/claim_history_spec.rb
271
- - spec/models/claim_spec.rb
272
- - spec/models/comment_spec.rb
273
- - spec/models/comment_thread_spec.rb
274
- - spec/models/configuration_spec.rb
275
- - spec/models/content_detail_spec.rb
276
- - spec/models/content_owner_detail_spec.rb
277
- - spec/models/file_detail_spec.rb
278
- - spec/models/live_streaming_detail_spec.rb
279
- - spec/models/ownership_spec.rb
280
- - spec/models/player_spec.rb
281
- - spec/models/playlist_item_spec.rb
282
- - spec/models/playlist_spec.rb
283
- - spec/models/policy_rule_spec.rb
284
- - spec/models/policy_spec.rb
285
- - spec/models/rating_spec.rb
286
- - spec/models/reference_spec.rb
287
- - spec/models/request_spec.rb
288
- - spec/models/resource_spec.rb
289
- - spec/models/right_owner_spec.rb
290
- - spec/models/snippet_spec.rb
291
- - spec/models/statistics_set_spec.rb
292
- - spec/models/status_spec.rb
293
- - spec/models/subscription_spec.rb
294
- - spec/models/url_spec.rb
295
- - spec/models/video_category_spec.rb
296
- - spec/models/video_spec.rb
297
- - spec/requests/as_account/account_spec.rb
298
- - spec/requests/as_account/authentications_spec.rb
299
- - spec/requests/as_account/channel_spec.rb
300
- - spec/requests/as_account/channels_spec.rb
301
- - spec/requests/as_account/playlist_item_spec.rb
302
- - spec/requests/as_account/playlist_spec.rb
303
- - spec/requests/as_account/thumbnail.jpg
304
- - spec/requests/as_account/video.mp4
305
- - spec/requests/as_account/video_spec.rb
306
- - spec/requests/as_content_owner/account_spec.rb
307
- - spec/requests/as_content_owner/advertising_options_set_spec.rb
308
- - spec/requests/as_content_owner/asset_spec.rb
309
- - spec/requests/as_content_owner/bulk_report_job_spec.rb
310
- - spec/requests/as_content_owner/channel_spec.rb
311
- - spec/requests/as_content_owner/claim_history_spec.rb
312
- - spec/requests/as_content_owner/claim_spec.rb
313
- - spec/requests/as_content_owner/content_owner_spec.rb
314
- - spec/requests/as_content_owner/match_policy_spec.rb
315
- - spec/requests/as_content_owner/ownership_spec.rb
316
- - spec/requests/as_content_owner/playlist_spec.rb
317
- - spec/requests/as_content_owner/video_group_spec.rb
318
- - spec/requests/as_content_owner/video_spec.rb
319
- - spec/requests/as_server_app/channel_spec.rb
320
- - spec/requests/as_server_app/comment_spec.rb
321
- - spec/requests/as_server_app/comment_thread_spec.rb
322
- - spec/requests/as_server_app/comment_threads_spec.rb
323
- - spec/requests/as_server_app/playlist_item_spec.rb
324
- - spec/requests/as_server_app/playlist_spec.rb
325
- - spec/requests/as_server_app/url_spec.rb
326
- - spec/requests/as_server_app/video_spec.rb
327
- - spec/requests/as_server_app/videos_spec.rb
328
- - spec/requests/unauthenticated/video_spec.rb
329
- - spec/spec_helper.rb
330
- - spec/support/fail_matcher.rb
331
- - spec/support/global_hooks.rb
332
277
  - yt.gemspec
333
278
  homepage: http://github.com/Fullscreen/yt
334
279
  licenses:
@@ -354,87 +299,4 @@ signing_key:
354
299
  specification_version: 4
355
300
  summary: Yt makes it easy to interact with Youtube V3 API by providing a modular,
356
301
  intuitive and tested Ruby-style API.
357
- test_files:
358
- - spec/collections/claims_spec.rb
359
- - spec/collections/comment_threads_spec.rb
360
- - spec/collections/playlist_items_spec.rb
361
- - spec/collections/playlists_spec.rb
362
- - spec/collections/policies_spec.rb
363
- - spec/collections/references_spec.rb
364
- - spec/collections/reports_spec.rb
365
- - spec/collections/subscriptions_spec.rb
366
- - spec/collections/videos_spec.rb
367
- - spec/constants/geography_spec.rb
368
- - spec/errors/forbidden_spec.rb
369
- - spec/errors/missing_auth_spec.rb
370
- - spec/errors/no_items_spec.rb
371
- - spec/errors/request_error_spec.rb
372
- - spec/errors/server_error_spec.rb
373
- - spec/errors/unauthorized_spec.rb
374
- - spec/models/account_spec.rb
375
- - spec/models/annotation_spec.rb
376
- - spec/models/asset_spec.rb
377
- - spec/models/channel_spec.rb
378
- - spec/models/claim_event_spec.rb
379
- - spec/models/claim_history_spec.rb
380
- - spec/models/claim_spec.rb
381
- - spec/models/comment_spec.rb
382
- - spec/models/comment_thread_spec.rb
383
- - spec/models/configuration_spec.rb
384
- - spec/models/content_detail_spec.rb
385
- - spec/models/content_owner_detail_spec.rb
386
- - spec/models/file_detail_spec.rb
387
- - spec/models/live_streaming_detail_spec.rb
388
- - spec/models/ownership_spec.rb
389
- - spec/models/player_spec.rb
390
- - spec/models/playlist_item_spec.rb
391
- - spec/models/playlist_spec.rb
392
- - spec/models/policy_rule_spec.rb
393
- - spec/models/policy_spec.rb
394
- - spec/models/rating_spec.rb
395
- - spec/models/reference_spec.rb
396
- - spec/models/request_spec.rb
397
- - spec/models/resource_spec.rb
398
- - spec/models/right_owner_spec.rb
399
- - spec/models/snippet_spec.rb
400
- - spec/models/statistics_set_spec.rb
401
- - spec/models/status_spec.rb
402
- - spec/models/subscription_spec.rb
403
- - spec/models/url_spec.rb
404
- - spec/models/video_category_spec.rb
405
- - spec/models/video_spec.rb
406
- - spec/requests/as_account/account_spec.rb
407
- - spec/requests/as_account/authentications_spec.rb
408
- - spec/requests/as_account/channel_spec.rb
409
- - spec/requests/as_account/channels_spec.rb
410
- - spec/requests/as_account/playlist_item_spec.rb
411
- - spec/requests/as_account/playlist_spec.rb
412
- - spec/requests/as_account/thumbnail.jpg
413
- - spec/requests/as_account/video.mp4
414
- - spec/requests/as_account/video_spec.rb
415
- - spec/requests/as_content_owner/account_spec.rb
416
- - spec/requests/as_content_owner/advertising_options_set_spec.rb
417
- - spec/requests/as_content_owner/asset_spec.rb
418
- - spec/requests/as_content_owner/bulk_report_job_spec.rb
419
- - spec/requests/as_content_owner/channel_spec.rb
420
- - spec/requests/as_content_owner/claim_history_spec.rb
421
- - spec/requests/as_content_owner/claim_spec.rb
422
- - spec/requests/as_content_owner/content_owner_spec.rb
423
- - spec/requests/as_content_owner/match_policy_spec.rb
424
- - spec/requests/as_content_owner/ownership_spec.rb
425
- - spec/requests/as_content_owner/playlist_spec.rb
426
- - spec/requests/as_content_owner/video_group_spec.rb
427
- - spec/requests/as_content_owner/video_spec.rb
428
- - spec/requests/as_server_app/channel_spec.rb
429
- - spec/requests/as_server_app/comment_spec.rb
430
- - spec/requests/as_server_app/comment_thread_spec.rb
431
- - spec/requests/as_server_app/comment_threads_spec.rb
432
- - spec/requests/as_server_app/playlist_item_spec.rb
433
- - spec/requests/as_server_app/playlist_spec.rb
434
- - spec/requests/as_server_app/url_spec.rb
435
- - spec/requests/as_server_app/video_spec.rb
436
- - spec/requests/as_server_app/videos_spec.rb
437
- - spec/requests/unauthenticated/video_spec.rb
438
- - spec/spec_helper.rb
439
- - spec/support/fail_matcher.rb
440
- - spec/support/global_hooks.rb
302
+ test_files: []
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/collections/claims'
3
- require 'yt/models/content_owner'
4
-
5
- describe Yt::Collections::Claims do
6
- let(:content_owner) { Yt::ContentOwner.new owner_name: 'any-name' }
7
- let(:collection) { Yt::Collections::Claims.new parent: content_owner, auth: content_owner }
8
- let(:page) { {items: [], token: 'any-token'} }
9
- let(:query) { {q: 'search string'} }
10
-
11
- describe "#insert" do
12
- let(:attributes) {
13
- {
14
- asset_id: 'some_asset_id',
15
- video_id: 'some_video_id',
16
- content_type: 'audiovisual',
17
- policy: { id: 'some_policy_id' },
18
- match_info: { match_segments: [ { manual_segment: { start: "00:01:00.000", finish: "00:02:00.000" } } ] },
19
- is_manual_claim: true
20
- }
21
- }
22
-
23
- before do
24
- allow(collection).to receive(:do_insert)
25
- collection.insert(attributes.deep_dup)
26
- end
27
-
28
- it 'calls do_insert with appropriate body' do
29
- body = {
30
- asset_id: 'some_asset_id',
31
- video_id: 'some_video_id',
32
- content_type: 'audiovisual',
33
- policy: { id: 'some_policy_id' },
34
- match_info: { matchSegments: [ { manual_segment: { start: "00:01:00.000", finish: "00:02:00.000" } } ] }
35
- }
36
- expect(collection).to have_received(:do_insert).with(
37
- params: { is_manual_claim: true, on_behalf_of_content_owner: content_owner.owner_name },
38
- body: body
39
- )
40
- end
41
- end
42
-
43
- describe '#count' do
44
- context 'called once with .where(query) and once without' do
45
- after do
46
- collection.where(query).count
47
- collection.count
48
- end
49
-
50
- it 'only applies the query on the first call' do
51
- expect(collection).to receive(:fetch_page) do |options|
52
- expect(options[:params]).to include query
53
- page
54
- end
55
- expect(collection).to receive(:fetch_page) do |options|
56
- expect(options[:params]).not_to include query
57
- page
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/collections/comment_threads'
3
- require 'yt/models/video'
4
- require 'yt/models/channel'
5
-
6
- describe Yt::Collections::CommentThreads do
7
- subject(:collection) { Yt::Collections::CommentThreads.new parent: parent}
8
-
9
- describe '#size', :ruby2 do
10
- describe 'sends only one request and return the total results' do
11
- let(:total_results) { 1234 }
12
- let(:parent) { Yt::Video.new id: 'any-id' }
13
-
14
- before do
15
- expect_any_instance_of(Yt::Request).to receive(:run).once do
16
- double(body: {'pageInfo'=>{'totalResults'=>total_results}})
17
- end
18
- end
19
- it { expect(collection.size).to be total_results }
20
- end
21
- end
22
-
23
- describe '#count' do
24
- let(:query) { {q: 'search string'} }
25
- let(:parent) { Yt::Video.new id: 'any-id' }
26
- let(:page) { {items: [], token: 'any-token'} }
27
-
28
- context 'called once with .where(query) and once without' do
29
- after do
30
- collection.where(query).count
31
- collection.count
32
- end
33
-
34
- it 'only applies the query on the first call' do
35
- expect(collection).to receive(:fetch_page) do |options|
36
- expect(options[:params]).to include query
37
- page
38
- end
39
- expect(collection).to receive(:fetch_page) do |options|
40
- expect(options[:params]).not_to include query
41
- page
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/models/playlist'
3
- require 'yt/models/playlist_item'
4
- require 'yt/collections/playlist_items'
5
-
6
- describe Yt::Collections::PlaylistItems do
7
- subject(:collection) { Yt::Collections::PlaylistItems.new parent: playlist }
8
- let(:playlist) { Yt::Playlist.new id: 'LLxO1tY8h1AhOz0T4ENwmpow' }
9
- let(:attrs) { {id: '9bZkp7q19f0', kind: :video} }
10
- let(:msg) { {response_body: {error: {errors: [{reason: reason}]}}}.to_json }
11
- before { expect(collection).to behave }
12
-
13
- describe '#insert' do
14
- let(:playlist_item) { Yt::PlaylistItem.new }
15
-
16
- context 'given an existing video' do
17
- let(:behave) { receive(:do_insert).and_return playlist_item }
18
-
19
- it { expect(collection.insert attrs).to eq playlist_item }
20
- end
21
-
22
- context 'given an unknown video' do
23
- let(:reason) { 'videoNotFound' }
24
- let(:behave) { receive(:do_insert).and_raise Yt::Error, msg }
25
-
26
- it { expect{collection.insert attrs}.to fail.with 'videoNotFound' }
27
- it { expect{collection.insert attrs, ignore_errors: true}.not_to fail }
28
- end
29
-
30
- context 'given a forbidden video' do
31
- let(:reason) { 'forbidden' }
32
- let(:behave) { receive(:do_insert).and_raise Yt::Error, msg }
33
-
34
- it { expect{collection.insert attrs}.to fail.with 'forbidden' }
35
- it { expect{collection.insert attrs, ignore_errors: true}.not_to fail }
36
- end
37
- end
38
-
39
- describe '#delete_all' do
40
- let(:behave) { receive(:do_delete_all).and_return [true] }
41
-
42
- it { expect(collection.delete_all).to eq [true] }
43
- end
44
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/collections/playlists'
3
-
4
- describe Yt::Collections::Playlists do
5
- subject(:collection) { Yt::Collections::Playlists.new }
6
- before { expect(collection).to behave }
7
-
8
- describe '#insert' do
9
- let(:playlist) { Yt::Playlist.new }
10
- # TODO: separate stubs to show options translate into do_insert params
11
- let(:behave) { receive(:do_insert).and_return playlist }
12
-
13
- it { expect(collection.insert).to eq playlist }
14
- end
15
-
16
- describe '#delete_all' do
17
- let(:behave) { receive(:do_delete_all).and_return [true] }
18
-
19
- it { expect(collection.delete_all).to eq [true] }
20
- end
21
-
22
- describe '#delete_all' do
23
- let(:behave) { receive(:do_delete_all).and_return [true] }
24
-
25
- it { expect(collection.delete_all).to eq [true] }
26
- end
27
- end