yt 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/HISTORY.md +3 -0
  4. data/README.md +2 -4
  5. data/bin/yt +0 -7
  6. data/lib/yt/actions/delete.rb +3 -3
  7. data/lib/yt/actions/insert.rb +3 -3
  8. data/lib/yt/actions/list.rb +4 -6
  9. data/lib/yt/actions/update.rb +7 -5
  10. data/lib/yt/associations/authentications.rb +114 -0
  11. data/lib/yt/associations.rb +1 -0
  12. data/lib/yt/collections/annotations.rb +2 -2
  13. data/lib/yt/collections/authentications.rb +42 -0
  14. data/lib/yt/collections/base.rb +1 -1
  15. data/lib/yt/collections/playlist_items.rb +1 -1
  16. data/lib/yt/collections/snippets.rb +1 -2
  17. data/lib/yt/collections/subscriptions.rb +1 -1
  18. data/lib/yt/collections/user_infos.rb +2 -2
  19. data/lib/yt/config.rb +0 -2
  20. data/lib/yt/errors/missing_auth.rb +50 -0
  21. data/lib/yt/errors/no_items.rb +5 -9
  22. data/lib/yt/errors/request_error.rb +52 -0
  23. data/lib/yt/models/account.rb +17 -44
  24. data/lib/yt/models/annotation.rb +117 -115
  25. data/lib/yt/models/authentication.rb +27 -0
  26. data/lib/yt/models/base.rb +9 -5
  27. data/lib/yt/models/channel.rb +6 -4
  28. data/lib/yt/models/configuration.rb +27 -35
  29. data/lib/yt/models/description.rb +61 -59
  30. data/lib/yt/models/details_set.rb +26 -24
  31. data/lib/yt/models/id.rb +3 -1
  32. data/lib/yt/models/playlist.rb +38 -36
  33. data/lib/yt/models/playlist_item.rb +29 -27
  34. data/lib/yt/models/rating.rb +18 -16
  35. data/lib/yt/models/request.rb +95 -73
  36. data/lib/yt/models/resource.rb +19 -17
  37. data/lib/yt/models/snippet.rb +39 -37
  38. data/lib/yt/models/status.rb +20 -18
  39. data/lib/yt/models/subscription.rb +24 -22
  40. data/lib/yt/models/url.rb +68 -68
  41. data/lib/yt/models/user_info.rb +51 -49
  42. data/lib/yt/models/video.rb +6 -4
  43. data/lib/yt/version.rb +1 -1
  44. data/spec/associations/device_auth/authentications_spec.rb +78 -0
  45. data/spec/associations/device_auth/channels_spec.rb +2 -4
  46. data/spec/associations/device_auth/details_sets_spec.rb +4 -5
  47. data/spec/associations/device_auth/ids_spec.rb +2 -3
  48. data/spec/associations/device_auth/playlist_items_spec.rb +3 -4
  49. data/spec/associations/device_auth/playlists_spec.rb +14 -15
  50. data/spec/associations/device_auth/ratings_spec.rb +2 -4
  51. data/spec/associations/device_auth/snippets_spec.rb +5 -7
  52. data/spec/associations/device_auth/subscriptions_spec.rb +2 -4
  53. data/spec/associations/device_auth/user_infos_spec.rb +2 -5
  54. data/spec/associations/device_auth/videos_spec.rb +3 -5
  55. data/spec/associations/server_auth/details_sets_spec.rb +1 -1
  56. data/spec/associations/server_auth/ids_spec.rb +1 -1
  57. data/spec/associations/server_auth/playlist_items_spec.rb +1 -1
  58. data/spec/associations/server_auth/playlists_spec.rb +1 -1
  59. data/spec/associations/server_auth/snippets_spec.rb +1 -1
  60. data/spec/associations/server_auth/videos_spec.rb +1 -1
  61. data/spec/collections/playlist_items_spec.rb +3 -4
  62. data/spec/collections/subscriptions_spec.rb +2 -3
  63. data/spec/errors/missing_auth_spec.rb +10 -0
  64. data/spec/errors/no_items_spec.rb +2 -1
  65. data/spec/errors/request_error_spec.rb +18 -0
  66. data/spec/models/configuration_spec.rb +0 -17
  67. data/spec/models/description_spec.rb +5 -5
  68. data/spec/models/request_spec.rb +1 -7
  69. data/spec/models/subscription_spec.rb +2 -3
  70. data/spec/models/url_spec.rb +6 -6
  71. data/spec/support/fail_matcher.rb +1 -1
  72. data/spec/support/global_hooks.rb +33 -0
  73. metadata +15 -14
  74. data/lib/yt/errors/base.rb +0 -43
  75. data/lib/yt/errors/error.rb +0 -8
  76. data/lib/yt/errors/failed.rb +0 -17
  77. data/lib/yt/errors/unauthenticated.rb +0 -34
  78. data/spec/errors/failed_spec.rb +0 -9
  79. data/spec/errors/unauthenticated_spec.rb +0 -9
  80. data/spec/support/device_app.rb +0 -15
  81. data/spec/support/server_app.rb +0 -10
@@ -3,7 +3,7 @@ require 'yt/associations/snippets'
3
3
  require 'yt/models/channel'
4
4
  require 'yt/models/video'
5
5
 
6
- describe Yt::Associations::Snippets, scenario: :server_app do
6
+ describe Yt::Associations::Snippets, :server_app do
7
7
  describe '#snippet' do
8
8
  context 'given an existing video resource' do
9
9
  let(:video) { Yt::Video.new id: 'MESycYJytkU' }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/videos'
3
3
 
4
- describe Yt::Associations::Videos, scenario: :server_app do
4
+ describe Yt::Associations::Videos, :server_app do
5
5
  describe '#videos' do
6
6
  context 'given a channel with videos' do
7
7
  let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow' }
@@ -6,8 +6,7 @@ describe Yt::Collections::PlaylistItems do
6
6
  subject(:collection) { Yt::Collections::PlaylistItems.new parent: playlist }
7
7
  let(:playlist) { Yt::Playlist.new id: 'LLxO1tY8h1AhOz0T4ENwmpow' }
8
8
  let(:attrs) { {id: 'MESycYJytkU', kind: :video} }
9
- let(:response_body) { %Q{{"error":{"errors":[{"reason":"#{reason}"}]}}} }
10
- let(:msg) { {response: {body: response_body}}.to_json }
9
+ let(:msg) { {response_body: {error: {errors: [{reason: reason}]}}}.to_json }
11
10
 
12
11
  describe '#insert' do
13
12
  let(:playlist_item) { Yt::PlaylistItem.new }
@@ -20,7 +19,7 @@ describe Yt::Collections::PlaylistItems do
20
19
 
21
20
  context 'given an unknown video' do
22
21
  let(:reason) { 'videoNotFound' }
23
- before { collection.stub(:do_insert).and_raise Yt::Errors::Failed, msg }
22
+ before { collection.stub(:do_insert).and_raise Yt::Error, msg }
24
23
 
25
24
  it { expect{collection.insert attrs}.to fail.with 'videoNotFound' }
26
25
  it { expect{collection.insert attrs, ignore_errors: true}.not_to fail }
@@ -28,7 +27,7 @@ describe Yt::Collections::PlaylistItems do
28
27
 
29
28
  context 'given a forbidden video' do
30
29
  let(:reason) { 'forbidden' }
31
- before { collection.stub(:do_insert).and_raise Yt::Errors::Failed, msg }
30
+ before { collection.stub(:do_insert).and_raise Yt::Error, msg }
32
31
 
33
32
  it { expect{collection.insert attrs}.to fail.with 'forbidden' }
34
33
  it { expect{collection.insert attrs, ignore_errors: true}.not_to fail }
@@ -4,8 +4,7 @@ require 'yt/collections/subscriptions'
4
4
  describe Yt::Collections::Subscriptions do
5
5
  subject(:collection) { Yt::Collections::Subscriptions.new }
6
6
  before { collection.stub :throttle }
7
- let(:response_body) { %Q{{"error":{"errors":[{"reason":"#{reason}"}]}}} }
8
- let(:msg) { {response: {body: response_body}}.to_json }
7
+ let(:msg) { {response_body: {error: {errors: [{reason: reason}]}}}.to_json }
9
8
 
10
9
  describe '#insert' do
11
10
  context 'given a new subscription' do
@@ -17,7 +16,7 @@ describe Yt::Collections::Subscriptions do
17
16
 
18
17
  context 'given a duplicate subscription' do
19
18
  let(:reason) { 'subscriptionDuplicate' }
20
- before { collection.stub(:do_insert).and_raise Yt::Errors::Failed, msg }
19
+ before { collection.stub(:do_insert).and_raise Yt::Error, msg }
21
20
 
22
21
  it { expect{collection.insert}.to fail.with 'subscriptionDuplicate' }
23
22
  it { expect{collection.insert ignore_errors: true}.not_to fail }
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+ require 'yt/errors/missing_auth'
3
+
4
+ describe Yt::Errors::MissingAuth do
5
+ let(:msg) { %r{^A request to YouTube API was sent without a valid authentication} }
6
+
7
+ describe '#exception' do
8
+ it { expect{raise Yt::Errors::MissingAuth}.to raise_error msg }
9
+ end
10
+ end
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
  require 'yt/errors/no_items'
3
3
 
4
4
  describe Yt::Errors::NoItems do
5
- let(:msg) { %r{request.+?returned no items} }
5
+ let(:msg) { %r{^A request to YouTube API returned no items} }
6
+
6
7
  describe '#exception' do
7
8
  it { expect{raise Yt::Errors::NoItems}.to raise_error msg }
8
9
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'yt/errors/request_error'
3
+
4
+ describe Yt::Errors::RequestError do
5
+ let(:msg) { %r{^A request to YouTube API failed} }
6
+
7
+ describe '#exception' do
8
+ it { expect{raise Yt::Errors::RequestError}.to raise_error msg }
9
+ end
10
+ end
11
+
12
+ describe Yt::Error do
13
+ let(:msg) { %r{^A request to YouTube API failed} }
14
+
15
+ describe '#exception' do
16
+ it { expect{raise Yt::Error}.to raise_error msg }
17
+ end
18
+ end
@@ -3,23 +3,6 @@ require 'spec_helper'
3
3
  describe Yt::Configuration do
4
4
  subject(:config) { Yt::Configuration.new }
5
5
 
6
- describe '#scenario' do
7
- context 'without an environment variable YT_CLIENT_SCENARIO' do
8
- before { ENV['YT_CLIENT_SCENARIO'] = nil }
9
- it {expect(config.scenario).to be :web_app }
10
- end
11
-
12
- context 'given an invalid environment variable YT_CLIENT_SCENARIO' do
13
- before { ENV['YT_CLIENT_SCENARIO'] = 'not-a-scenario'}
14
- it {expect(config.scenario).to be :web_app }
15
- end
16
-
17
- context 'given a valid environment variable YT_CLIENT_SCENARIO' do
18
- before { ENV['YT_CLIENT_SCENARIO'] = 'device_app'}
19
- it {expect(config.scenario).to be :device_app }
20
- end
21
- end
22
-
23
6
  describe '#client_id' do
24
7
  context 'without an environment variable YT_CLIENT_ID' do
25
8
  before { ENV['YT_CLIENT_ID'] = nil }
@@ -29,6 +29,11 @@ describe Yt::Description do
29
29
  let(:text) { 'Link to video: youtu.be/MESycYJytkU' }
30
30
  it { expect(description).to have_link_to_video }
31
31
  end
32
+
33
+ context 'with a playlist-embedded video URL' do
34
+ let(:text) { 'Link to video in playlist: youtube.com/watch?v=MESycYJytkU&index=619&list=LLxO1tY8h1AhOz0T4ENwmpow' }
35
+ it { expect(description).to have_link_to_video }
36
+ end
32
37
  end
33
38
 
34
39
  describe '#has_link_to_channel?' do
@@ -85,10 +90,5 @@ describe Yt::Description do
85
90
  let(:text) { 'Link to playlist: youtube.com/playlist?list=LLxO1tY8h1AhOz0T4ENwmpow' }
86
91
  it { expect(description).to have_link_to_playlist }
87
92
  end
88
-
89
- context 'with a playlist embed URL' do
90
- let(:text) { 'Link to video in playlist: youtube.com/watch?v=MESycYJytkU&index=619&list=LLxO1tY8h1AhOz0T4ENwmpow' }
91
- it { expect(description).to have_link_to_playlist }
92
- end
93
93
  end
94
94
  end
@@ -3,15 +3,9 @@ require 'yt/models/request'
3
3
 
4
4
  describe Yt::Request do
5
5
  subject(:request) { Yt::Request.new attrs }
6
- let(:attrs) { {} }
6
+ let(:attrs) { {host: 'example.com'} }
7
7
 
8
8
  describe '#run' do
9
- context 'given a request to YouTube V3 API without authentication' do
10
- let(:attrs) { {host: 'www.googleapis.com'} }
11
- before{ Yt.configuration.api_key = nil }
12
- it { expect{request.run}.to raise_error Yt::Errors::Unauthenticated }
13
- end
14
-
15
9
  context 'given a request that returns a non-2XX code' do
16
10
  let(:not_found) { Net::HTTPNotFound.new nil, nil, nil }
17
11
  before { Net::HTTP.stub(:start).and_return not_found }
@@ -3,8 +3,7 @@ require 'yt/models/subscription'
3
3
 
4
4
  describe Yt::Subscription do
5
5
  subject(:subscription) { Yt::Subscription.new id: id }
6
- let(:response_body) { %Q{{"error":{"errors":[{"reason":"#{reason}"}]}}} }
7
- let(:msg) { {response: {body: response_body}}.to_json }
6
+ let(:msg) { {response_body: {error: {errors: [{reason: reason}]}}}.to_json }
8
7
 
9
8
  describe '#exists?' do
10
9
  context 'given a subscription with an id' do
@@ -30,7 +29,7 @@ describe Yt::Subscription do
30
29
 
31
30
  context 'given an unknown subscription' do
32
31
  let(:reason) { 'subscriptionNotFound' }
33
- before { subscription.stub(:do_delete).and_raise Yt::Errors::Failed, msg }
32
+ before { subscription.stub(:do_delete).and_raise Yt::Error, msg }
34
33
 
35
34
  it { expect{subscription.delete}.to fail.with 'subscriptionNotFound' }
36
35
  it { expect{subscription.delete ignore_errors: true}.not_to fail }
@@ -19,6 +19,12 @@ describe Yt::URL do
19
19
  it {expect(url.id).to eq 'MESycYJytkU' }
20
20
  end
21
21
 
22
+ context 'given a playlist-embedded video URL' do
23
+ let(:text) { 'youtube.com/watch?v=MESycYJytkU&list=LLxO1tY8h1AhOz0T4ENwmpow' }
24
+ it {expect(url.kind).to eq :video }
25
+ it {expect(url.id).to eq 'MESycYJytkU' }
26
+ end
27
+
22
28
  context 'given a long channel URL' do
23
29
  let(:text) { 'http://youtube.com/channel/UCxO1tY8h1AhOz0T4ENwmpow' }
24
30
  it {expect(url.kind).to eq :channel }
@@ -59,12 +65,6 @@ describe Yt::URL do
59
65
  it {expect(url.id).to eq 'LLxO1tY8h1AhOz0T4ENwmpow' }
60
66
  end
61
67
 
62
- context 'given a video-embed playlist URL' do
63
- let(:text) { 'youtube.com/watch?v=MESycYJytkU&list=LLxO1tY8h1AhOz0T4ENwmpow' }
64
- it {expect(url.kind).to eq :playlist }
65
- it {expect(url.id).to eq 'LLxO1tY8h1AhOz0T4ENwmpow' }
66
- end
67
-
68
68
  context 'given a valid URL with a trailing slash' do
69
69
  let(:text) { 'https://www.youtube.com/user/Fullscreen/' }
70
70
  it {expect(url.kind).to eq :channel }
@@ -3,7 +3,7 @@ RSpec::Matchers.define :fail do
3
3
  begin
4
4
  block.call
5
5
  false
6
- rescue Yt::Errors::Base => error
6
+ rescue Yt::Error => error
7
7
  @reason ? error.reasons.include?(@reason) : true
8
8
  end
9
9
  end
@@ -0,0 +1,33 @@
1
+ require 'yt/config'
2
+ require 'yt/models/account'
3
+
4
+ RSpec.configure do |config|
5
+ # Create one global test account to avoid having to refresh the access token
6
+ # at every request
7
+ config.before :all do
8
+ attrs = {refresh_token: ENV['YT_TEST_DEVICE_REFRESH_TOKEN']}
9
+ $account = Yt::Account.new attrs
10
+ end
11
+
12
+ # Don't use authentication from env variables unless specified with a tag
13
+ config.before :all do
14
+ Yt.configure do |config|
15
+ config.client_id = nil
16
+ config.client_secret = nil
17
+ config.api_key = nil
18
+ end
19
+ end
20
+
21
+ config.before :all, device_app: true do
22
+ Yt.configure do |config|
23
+ config.client_id = ENV['YT_TEST_DEVICE_CLIENT_ID']
24
+ config.client_secret = ENV['YT_TEST_DEVICE_CLIENT_SECRET']
25
+ end
26
+ end
27
+
28
+ config.before :all, server_app: true do
29
+ Yt.configure do |config|
30
+ config.api_key = ENV['YT_TEST_SERVER_API_KEY']
31
+ end
32
+ end
33
+ 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.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-19 00:00:00.000000000 Z
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -124,6 +124,7 @@ files:
124
124
  - lib/yt/actions/update.rb
125
125
  - lib/yt/associations.rb
126
126
  - lib/yt/associations/annotations.rb
127
+ - lib/yt/associations/authentications.rb
127
128
  - lib/yt/associations/channels.rb
128
129
  - lib/yt/associations/details_sets.rb
129
130
  - lib/yt/associations/ids.rb
@@ -136,6 +137,7 @@ files:
136
137
  - lib/yt/associations/user_infos.rb
137
138
  - lib/yt/associations/videos.rb
138
139
  - lib/yt/collections/annotations.rb
140
+ - lib/yt/collections/authentications.rb
139
141
  - lib/yt/collections/base.rb
140
142
  - lib/yt/collections/channels.rb
141
143
  - lib/yt/collections/details_sets.rb
@@ -148,13 +150,12 @@ files:
148
150
  - lib/yt/collections/user_infos.rb
149
151
  - lib/yt/collections/videos.rb
150
152
  - lib/yt/config.rb
151
- - lib/yt/errors/base.rb
152
- - lib/yt/errors/error.rb
153
- - lib/yt/errors/failed.rb
153
+ - lib/yt/errors/missing_auth.rb
154
154
  - lib/yt/errors/no_items.rb
155
- - lib/yt/errors/unauthenticated.rb
155
+ - lib/yt/errors/request_error.rb
156
156
  - lib/yt/models/account.rb
157
157
  - lib/yt/models/annotation.rb
158
+ - lib/yt/models/authentication.rb
158
159
  - lib/yt/models/base.rb
159
160
  - lib/yt/models/channel.rb
160
161
  - lib/yt/models/configuration.rb
@@ -173,6 +174,7 @@ files:
173
174
  - lib/yt/models/user_info.rb
174
175
  - lib/yt/models/video.rb
175
176
  - lib/yt/version.rb
177
+ - spec/associations/device_auth/authentications_spec.rb
176
178
  - spec/associations/device_auth/channels_spec.rb
177
179
  - spec/associations/device_auth/details_sets_spec.rb
178
180
  - spec/associations/device_auth/ids_spec.rb
@@ -204,9 +206,9 @@ files:
204
206
  - spec/collections/subscriptions_spec.rb
205
207
  - spec/collections/user_infos_spec.rb
206
208
  - spec/collections/videos_spec.rb
207
- - spec/errors/failed_spec.rb
209
+ - spec/errors/missing_auth_spec.rb
208
210
  - spec/errors/no_items_spec.rb
209
- - spec/errors/unauthenticated_spec.rb
211
+ - spec/errors/request_error_spec.rb
210
212
  - spec/models/account_spec.rb
211
213
  - spec/models/annotation_spec.rb
212
214
  - spec/models/channel_spec.rb
@@ -225,9 +227,8 @@ files:
225
227
  - spec/models/user_info_spec.rb
226
228
  - spec/models/video_spec.rb
227
229
  - spec/spec_helper.rb
228
- - spec/support/device_app.rb
229
230
  - spec/support/fail_matcher.rb
230
- - spec/support/server_app.rb
231
+ - spec/support/global_hooks.rb
231
232
  - yt.gemspec
232
233
  homepage: http://github.com/Fullscreen/yt
233
234
  licenses:
@@ -255,6 +256,7 @@ specification_version: 4
255
256
  summary: Yt makes it easy to interact with Youtube V3 API by providing a modular,
256
257
  intuitive and tested Ruby-style API.
257
258
  test_files:
259
+ - spec/associations/device_auth/authentications_spec.rb
258
260
  - spec/associations/device_auth/channels_spec.rb
259
261
  - spec/associations/device_auth/details_sets_spec.rb
260
262
  - spec/associations/device_auth/ids_spec.rb
@@ -286,9 +288,9 @@ test_files:
286
288
  - spec/collections/subscriptions_spec.rb
287
289
  - spec/collections/user_infos_spec.rb
288
290
  - spec/collections/videos_spec.rb
289
- - spec/errors/failed_spec.rb
291
+ - spec/errors/missing_auth_spec.rb
290
292
  - spec/errors/no_items_spec.rb
291
- - spec/errors/unauthenticated_spec.rb
293
+ - spec/errors/request_error_spec.rb
292
294
  - spec/models/account_spec.rb
293
295
  - spec/models/annotation_spec.rb
294
296
  - spec/models/channel_spec.rb
@@ -307,7 +309,6 @@ test_files:
307
309
  - spec/models/user_info_spec.rb
308
310
  - spec/models/video_spec.rb
309
311
  - spec/spec_helper.rb
310
- - spec/support/device_app.rb
311
312
  - spec/support/fail_matcher.rb
312
- - spec/support/server_app.rb
313
+ - spec/support/global_hooks.rb
313
314
  has_rdoc:
@@ -1,43 +0,0 @@
1
- module Yt
2
- module Errors
3
- class Base < StandardError
4
- def initialize(msg = nil)
5
- @msg = msg
6
- super msg
7
- end
8
-
9
- def reasons
10
- errors = response_body.fetch('error', {}).fetch 'errors', []
11
- errors.map{|e| e['reason']}
12
- end
13
-
14
- private
15
-
16
- def response_code
17
- Integer(response['code']) rescue nil
18
- end
19
-
20
- def response_body
21
- body = response['body']
22
- JSON(body) rescue {body: body}
23
- end
24
-
25
- def request_curl
26
- # TODO.. continue
27
- %Q{curl -X #{request['method'].to_s.upcase} "#{request['url']}"}
28
- end
29
-
30
- def request
31
- json['request'] || {}
32
- end
33
-
34
- def response
35
- json['response'] || {}
36
- end
37
-
38
- def json
39
- JSON(@msg) rescue {}
40
- end
41
- end
42
- end
43
- end
@@ -1,8 +0,0 @@
1
- require 'yt/errors/base'
2
-
3
- # Just an alias in the main namespace, so external code can `rescue Yt::Error`
4
- # rather than `rescue Yt::Error::Base`
5
- module Yt
6
- class Error < Errors::Base
7
- end
8
- end
@@ -1,17 +0,0 @@
1
- require 'yt/errors/base'
2
-
3
- module Yt
4
- module Errors
5
- class Failed < Base
6
- def message
7
- <<-MSG.gsub(/^ {6}/, '')
8
- A request to YouTube API V3 failed (code #{response_code}):
9
- #{response_body}
10
-
11
- You can retry the same request manually by running:
12
- #{request_curl}
13
- MSG
14
- end
15
- end
16
- end
17
- end
@@ -1,34 +0,0 @@
1
- require 'yt/errors/base'
2
-
3
- module Yt
4
- module Errors
5
- class Unauthenticated < Base
6
- def message
7
- <<-MSG.gsub(/^ {6}/, '')
8
- A request to YouTube API V3 was sent without the required authentication:
9
-
10
- #{request_curl}
11
-
12
- In order to perform this request, you need to register your app with
13
- Google Developers Console (https://console.developers.google.com).
14
-
15
- Make sure your app has access to the Google+ and YouTube APIs.
16
- Generate a client ID, client secret and server API key, then pass their
17
- values to Yt. One way of doing this is through an initializer:
18
-
19
- Yt.configure do |config|
20
- config.client_id = '1234567890.apps.googleusercontent.com'
21
- config.client_secret = '1234567890'
22
- config.api_key = '123456789012345678901234567890'
23
- end
24
-
25
- An alternative (but equivalent) way is throught environment variables:
26
-
27
- export YT_CLIENT_ID="1234567890.apps.googleusercontent.com"
28
- export YT_CLIENT_SECRET="1234567890"
29
- export YT_API_KEY="123456789012345678901234567890"
30
- MSG
31
- end
32
- end
33
- end
34
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/errors/failed'
3
-
4
- describe Yt::Errors::Failed do
5
- let(:msg) { %r{request.+?failed} }
6
- describe '#exception' do
7
- it { expect{raise Yt::Errors::Failed}.to raise_error msg }
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
- require 'yt/errors/unauthenticated'
3
-
4
- describe Yt::Errors::Unauthenticated do
5
- let(:msg) { %r{request.+?without the required authentication} }
6
- describe '#exception' do
7
- it { expect{raise Yt::Errors::Unauthenticated}.to raise_error msg }
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- require 'yt/config'
2
- require 'yt/models/account'
3
-
4
- RSpec.configure do |config|
5
- config.before :all, scenario: :device_app do
6
- unless Yt.configuration.scenario == :device_app
7
- Yt.configure do |config|
8
- config.scenario = :device_app
9
- config.client_id = ENV['YT_TEST_DEVICE_CLIENT_ID']
10
- config.client_secret = ENV['YT_TEST_DEVICE_CLIENT_SECRET']
11
- config.account = Yt::Account.new refresh_token: ENV['YT_TEST_DEVICE_REFRESH_TOKEN']
12
- end
13
- end
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- require 'yt/config'
2
-
3
- RSpec.configure do |config|
4
- config.before :all, scenario: :server_app do
5
- Yt.configure do |config|
6
- config.scenario = :server_app
7
- config.api_key = ENV['YT_TEST_SERVER_API_KEY']
8
- end
9
- end
10
- end