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
data/lib/yt/models/url.rb CHANGED
@@ -1,88 +1,88 @@
1
1
  module Yt
2
- class URL
3
- attr_reader :kind
4
-
5
- def initialize(url)
6
- @url = url
7
- @kind ||= parse url
8
- @match_data ||= {}
9
- end
2
+ module Models
3
+ class URL
4
+ attr_reader :kind
5
+
6
+ def initialize(url)
7
+ @url = url
8
+ @kind ||= parse url
9
+ @match_data ||= {}
10
+ end
10
11
 
11
- def id
12
- @match_data[:id]
13
- rescue IndexError
14
- end
12
+ def id
13
+ @match_data[:id]
14
+ rescue IndexError
15
+ end
15
16
 
16
- def username
17
- @match_data[:username]
18
- rescue IndexError
19
- end
17
+ def username
18
+ @match_data[:username]
19
+ rescue IndexError
20
+ end
20
21
 
21
- private
22
+ private
22
23
 
23
- def parse(url)
24
- matching_pattern = patterns.find do |pattern|
25
- @match_data = url.match pattern[:regex]
24
+ def parse(url)
25
+ matching_pattern = patterns.find do |pattern|
26
+ @match_data = url.match pattern[:regex]
27
+ end
28
+ matching_pattern[:kind] if matching_pattern
26
29
  end
27
- matching_pattern[:kind] if matching_pattern
28
- end
29
30
 
30
- def patterns
31
- # @note: :video *must* be the last since one of its regex eats the
32
- # remaining patterns. In short, don't change the following order
31
+ def patterns
32
+ # @note: :channel *must* be the last since one of its regex eats the
33
+ # remaining patterns. In short, don't change the following order
33
34
 
34
- @patterns ||= patterns_for :playlist, :subscription, :channel, :video
35
- end
35
+ @patterns ||= patterns_for :playlist, :subscription, :video, :channel
36
+ end
36
37
 
37
- def patterns_for(*kinds)
38
- prefix = '^(?:https?://)?(?:www\.)?'
39
- suffix = '(?:|/)$'
40
- kinds.map do |kind|
41
- patterns = send "#{kind}_patterns" # meta programming :/
42
- patterns.map do |pattern|
43
- {kind: kind, regex: %r{#{prefix}#{pattern}#{suffix}}}
44
- end
45
- end.flatten
46
- end
38
+ def patterns_for(*kinds)
39
+ prefix = '^(?:https?://)?(?:www\.)?'
40
+ suffix = '(?:|/)'
41
+ kinds.map do |kind|
42
+ patterns = send "#{kind}_patterns" # meta programming :/
43
+ patterns.map do |pattern|
44
+ {kind: kind, regex: %r{#{prefix}#{pattern}#{suffix}}}
45
+ end
46
+ end.flatten
47
+ end
47
48
 
48
- def subscription_patterns
49
- name = '(?:[a-zA-Z0-9&_=-]*)'
49
+ def subscription_patterns
50
+ name = '(?:[a-zA-Z0-9&_=-]*)'
50
51
 
51
- %W{
52
- subscription_center\\?add_user=#{name}
53
- subscribe_widget\\?p=#{name}
54
- channel/#{name}\\?sub_confirmation=1
55
- }.map{|path| "youtube\\.com/#{path}"}
56
- end
52
+ %W{
53
+ subscription_center\\?add_user=#{name}
54
+ subscribe_widget\\?p=#{name}
55
+ channel/#{name}\\?sub_confirmation=1
56
+ }.map{|path| "youtube\\.com/#{path}"}
57
+ end
57
58
 
58
- def playlist_patterns
59
- playlist_id = '(?<id>[a-zA-Z0-9_-]+)'
60
- video_id = '(?:[a-zA-Z0-9&_=-]*)'
59
+ def playlist_patterns
60
+ playlist_id = '(?<id>[a-zA-Z0-9_-]+)'
61
61
 
62
- %W{
63
- playlist\\?list=#{playlist_id}
64
- watch\\?v=#{video_id}&list=#{playlist_id}
65
- }.map{|path| "youtube\\.com/#{path}"}
66
- end
62
+ %W{
63
+ playlist\\?list=#{playlist_id}
64
+ }.map{|path| "youtube\\.com/#{path}"}
65
+ end
67
66
 
68
- def video_patterns
69
- video_id = '(?<id>[a-zA-Z0-9_-]+)'
67
+ def video_patterns
68
+ video_id = '(?<id>[a-zA-Z0-9_-]+)'
70
69
 
71
- %W{
72
- youtube\\.com/watch\\?v=#{video_id}
73
- youtu\\.be/#{video_id}
74
- }
75
- end
70
+ %W{
71
+ youtube\\.com/watch\\?v=#{video_id}
72
+ youtu\\.be/#{video_id}
73
+ }
74
+ end
76
75
 
77
- def channel_patterns
78
- channel_id = '(?<id>[a-zA-Z0-9_-]+)'
79
- username = '(?<username>[a-zA-Z0-9_-]+)'
76
+ def channel_patterns
77
+ channel_id = '(?<id>[a-zA-Z0-9_-]+)'
78
+ username = '(?<username>[a-zA-Z0-9_-]+)'
80
79
 
81
- %W{
82
- channel/#{channel_id}
83
- user/#{username}
84
- #{username}
85
- }.map{|path| "youtube\\.com/#{path}"}
80
+ %W{
81
+ channel/#{channel_id}
82
+ user/#{username}
83
+ #{username}
84
+ }.map{|path| "youtube\\.com/#{path}"}
85
+ end
86
86
  end
87
87
  end
88
88
  end
@@ -1,66 +1,68 @@
1
1
  require 'yt/models/base'
2
2
 
3
3
  module Yt
4
- class UserInfo < Base
5
- def initialize(options = {})
6
- @data = options[:data]
7
- end
4
+ module Models
5
+ class UserInfo < Base
6
+ def initialize(options = {})
7
+ @data = options[:data]
8
+ end
8
9
 
9
- # @return [String] User ID
10
- def id
11
- @id ||= @data.fetch 'id', ''
12
- end
10
+ # @return [String] User ID
11
+ def id
12
+ @id ||= @data.fetch 'id', ''
13
+ end
13
14
 
14
- # Return the email of the YouTube account.
15
- #
16
- # @return [String] Email of the YouTube account
17
- def email
18
- @email ||= @data.fetch 'email', ''
19
- end
15
+ # Return the email of the YouTube account.
16
+ #
17
+ # @return [String] Email of the YouTube account
18
+ def email
19
+ @email ||= @data.fetch 'email', ''
20
+ end
20
21
 
21
- # @return [Boolean] Email is verified?
22
- def has_verified_email?
23
- @verified_email ||= @data.fetch 'verified_email', false
24
- end
22
+ # @return [Boolean] Email is verified?
23
+ def has_verified_email?
24
+ @verified_email ||= @data.fetch 'verified_email', false
25
+ end
25
26
 
26
- # @return [String] name
27
- def name
28
- @name ||= @data.fetch 'name', ''
29
- end
27
+ # @return [String] name
28
+ def name
29
+ @name ||= @data.fetch 'name', ''
30
+ end
30
31
 
31
- # @return [String] given_name
32
- def given_name
33
- @given_name ||= @data.fetch 'given_name', ''
34
- end
32
+ # @return [String] given_name
33
+ def given_name
34
+ @given_name ||= @data.fetch 'given_name', ''
35
+ end
35
36
 
36
- # @return [String] family_name
37
- def family_name
38
- @family_name ||= @data.fetch 'family_name', ''
39
- end
37
+ # @return [String] family_name
38
+ def family_name
39
+ @family_name ||= @data.fetch 'family_name', ''
40
+ end
40
41
 
41
- # @return [String] family_name
42
- def profile_url
43
- @profile_url ||= @data.fetch 'link', ''
44
- end
42
+ # @return [String] family_name
43
+ def profile_url
44
+ @profile_url ||= @data.fetch 'link', ''
45
+ end
45
46
 
46
- # @return [String] avatar_url
47
- def avatar_url
48
- @avatar_url ||= @data.fetch 'picture', ''
49
- end
47
+ # @return [String] avatar_url
48
+ def avatar_url
49
+ @avatar_url ||= @data.fetch 'picture', ''
50
+ end
50
51
 
51
- # @return [String] gender
52
- def gender
53
- @gender ||= @data.fetch 'gender', ''
54
- end
52
+ # @return [String] gender
53
+ def gender
54
+ @gender ||= @data.fetch 'gender', ''
55
+ end
55
56
 
56
- # @return [String] locale
57
- def locale
58
- @locale ||= @data.fetch 'locale', ''
59
- end
57
+ # @return [String] locale
58
+ def locale
59
+ @locale ||= @data.fetch 'locale', ''
60
+ end
60
61
 
61
- # @return [String] hd
62
- def hd
63
- @hd ||= @data.fetch 'hd', ''
62
+ # @return [String] hd
63
+ def hd
64
+ @hd ||= @data.fetch 'hd', ''
65
+ end
64
66
  end
65
67
  end
66
68
  end
@@ -1,9 +1,11 @@
1
1
  require 'yt/models/resource'
2
2
 
3
3
  module Yt
4
- class Video < Resource
5
- has_one :details_set, delegate: [:duration]
6
- has_one :rating
7
- has_many :annotations
4
+ module Models
5
+ class Video < Resource
6
+ has_one :details_set, delegate: [:duration]
7
+ has_one :rating
8
+ has_many :annotations
9
+ end
8
10
  end
9
11
  end
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.5.4'
2
+ VERSION = '0.5.5'
3
3
  end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'yt/associations/authentications'
3
+
4
+ describe Yt::Associations::Authentications, :device_app do
5
+ subject(:account) { Yt::Account.new attrs }
6
+
7
+ describe '#authentication' do
8
+ context 'given a refresh token' do
9
+ let(:attrs) { {refresh_token: refresh_token} }
10
+
11
+ context 'that is valid' do
12
+ let(:refresh_token) { ENV['YT_TEST_DEVICE_REFRESH_TOKEN'] }
13
+ it { expect(account.authentication).to be_a Yt::Authentication }
14
+ end
15
+
16
+ context 'that is invalid' do
17
+ let(:refresh_token) { '--not-a-valid-refresh-token--' }
18
+ it { expect{account.authentication}.to raise_error Yt::Errors::MissingAuth }
19
+ end
20
+ end
21
+
22
+ context 'given a redirect URI and an authorization code' do
23
+ let(:attrs) { {authorization_code: authorization_code, redirect_uri: 'http://localhost/'} }
24
+
25
+ context 'that is valid' do
26
+ # cannot be tested "live"
27
+ end
28
+
29
+ context 'that is invalid' do
30
+ let(:authorization_code) { '--not-a-valid-authorization-code--' }
31
+ it { expect{account.authentication}.to raise_error Yt::Errors::MissingAuth }
32
+ end
33
+ end
34
+
35
+ context 'given an access token' do
36
+ let(:attrs) { {access_token: access_token, expires_at: expires_at} }
37
+
38
+ context 'that is valid' do
39
+ let(:access_token) { $account.access_token }
40
+
41
+ context 'that does not have an expiration date' do
42
+ let(:expires_at) { nil }
43
+ it { expect(account.authentication).to be_a Yt::Authentication }
44
+ end
45
+
46
+ context 'that has not expired' do
47
+ let(:expires_at) { 1.day.from_now.to_s }
48
+ it { expect(account.authentication).to be_a Yt::Authentication }
49
+ end
50
+
51
+ context 'that has expired' do
52
+ let(:expires_at) { 1.day.ago.to_s }
53
+ it { expect{account.authentication}.to raise_error Yt::Errors::MissingAuth }
54
+ end
55
+ end
56
+
57
+ context 'that is invalid' do
58
+ let(:access_token) { '--not-a-valid-access-token--' }
59
+ let(:expires_at) { 1.day.from_now }
60
+ it { expect(account.authentication).to be_a Yt::Authentication }
61
+ it { expect{account.channel}.to raise_error Yt::Errors::MissingAuth }
62
+ end
63
+
64
+ end
65
+
66
+ context 'given no token or code' do
67
+ let(:attrs) { {} }
68
+ it { expect{account.authentication}.to raise_error Yt::Errors::MissingAuth }
69
+ end
70
+ end
71
+
72
+ describe '#authentication_url' do
73
+ context 'given a redirect URI and scopes' do
74
+ let(:attrs) { {redirect_uri: 'http://localhost/', scopes: ['userinfo.email', 'userinfo.profile']} }
75
+ it { expect(account.authentication_url).to match 'access_type=offline' }
76
+ end
77
+ end
78
+ end
@@ -1,10 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/channels'
3
3
 
4
- describe Yt::Associations::Channels, scenario: :device_app do
5
- let(:account) { Yt.configuration.account }
6
-
4
+ describe Yt::Associations::Channels, :device_app do
7
5
  describe '#channel' do
8
- it { expect(account.channel).to be_a Yt::Channel }
6
+ it { expect($account.channel).to be_a Yt::Channel }
9
7
  end
10
8
  end
@@ -1,18 +1,17 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/details_sets'
3
3
 
4
- describe Yt::Associations::DetailsSets, scenario: :device_app do
5
- let(:account) { Yt.configuration.account }
6
- let(:video) { Yt::Video.new id: 'fsdfsfsdMESycYJytkU', auth: account.auth }
4
+ describe Yt::Associations::DetailsSets, :device_app do
5
+ let(:video) { Yt::Video.new id: 'fsdfsfsdMESycYJytkU', auth: $account }
7
6
 
8
7
  describe '#details_set' do
9
8
  context 'given an existing video' do
10
- let(:video) { Yt::Video.new id: 'MESycYJytkU', auth: account }
9
+ let(:video) { Yt::Video.new id: 'MESycYJytkU', auth: $account }
11
10
  it { expect(video.details_set).to be_a Yt::DetailsSet }
12
11
  end
13
12
 
14
13
  context 'given an unknown video' do
15
- let(:video) { Yt::Video.new id: 'not-a-video-id', auth: account }
14
+ let(:video) { Yt::Video.new id: 'not-a-video-id', auth: $account }
16
15
  it { expect{video.details_set}.to raise_error Yt::Errors::NoItems }
17
16
  end
18
17
  end
@@ -1,9 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/ids'
3
3
 
4
- describe Yt::Associations::Ids, scenario: :device_app do
5
- let(:account) { Yt.configuration.account }
6
- subject(:resource) { Yt::Resource.new url: url, auth: account.auth }
4
+ describe Yt::Associations::Ids, :device_app do
5
+ subject(:resource) { Yt::Resource.new url: url, auth: $account }
7
6
 
8
7
  describe '#id' do
9
8
  context 'given a URL containing an existing username' do
@@ -3,10 +3,9 @@ require 'yt/associations/playlist_items'
3
3
 
4
4
  # TODO: Delete playlist item after tests that create them
5
5
 
6
- describe Yt::Associations::PlaylistItems, scenario: :device_app do
7
- before :all do
8
- account = Yt.configuration.account
9
- @playlist = account.create_playlist title: "Yt Test Playlist Items"
6
+ describe Yt::Associations::PlaylistItems, :device_app do
7
+ before:all do
8
+ @playlist = $account.create_playlist title: "Yt Test Playlist Items"
10
9
  end
11
10
  after(:all) { @playlist.delete }
12
11
 
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/playlists'
3
3
 
4
- describe Yt::Associations::Playlists, scenario: :device_app do
5
- let(:account) { Yt.configuration.account }
4
+ describe Yt::Associations::Playlists, :device_app do
6
5
  let(:title) { 'Yt Test title' }
7
6
  let(:description) { 'Yt Test description' }
8
7
  let(:tags) { ['Yt Test Tag 1', 'Yt Test Tag 2'] }
@@ -10,38 +9,38 @@ describe Yt::Associations::Playlists, scenario: :device_app do
10
9
  let(:params) { {title: title, description: description, tags: tags, privacy_status: privacy_status} }
11
10
 
12
11
  describe 'playlists' do
13
- before { account.create_playlist params }
14
- after { account.delete_playlists params }
12
+ before { $account.create_playlist params }
13
+ after { $account.delete_playlists params }
15
14
 
16
- it { expect(account.playlists.count).to be > 0 }
17
- it { expect(account.playlists.first).to be_a Yt::Playlist }
15
+ it { expect($account.playlists.count).to be > 0 }
16
+ it { expect($account.playlists.first).to be_a Yt::Playlist }
18
17
  end
19
18
 
20
19
  describe 'create a playlist' do
21
- after { account.delete_playlists params }
20
+ after { $account.delete_playlists params }
22
21
 
23
- it { expect(account.create_playlist params).to be_a Yt::Playlist }
24
- it { expect{account.create_playlist params}.to change{account.playlists.count}.by(1) }
22
+ it { expect($account.create_playlist params).to be_a Yt::Playlist }
23
+ it { expect{$account.create_playlist params}.to change{$account.playlists.count}.by(1) }
25
24
  end
26
25
 
27
26
  describe 'delete a playlist' do
28
27
  let(:title) { "Yt Test Delete Playlist #{rand}" }
29
- before { @playlist = account.create_playlist params }
28
+ before { @playlist = $account.create_playlist params }
30
29
 
31
30
  it { expect(@playlist.delete).to be true }
32
31
  end
33
32
 
34
33
  describe 'delete a set of playlists' do
35
34
  let(:title) { "Yt Test Delete All Playlists #{rand}" }
36
- before { account.create_playlist params }
35
+ before { $account.create_playlist params }
37
36
 
38
- it { expect(account.delete_playlists title: %r{#{params[:title]}}).to eq [true] }
39
- it { expect(account.delete_playlists params).to eq [true] }
40
- it { expect{account.delete_playlists params}.to change{account.playlists.count}.by(-1) }
37
+ it { expect($account.delete_playlists title: %r{#{params[:title]}}).to eq [true] }
38
+ it { expect($account.delete_playlists params).to eq [true] }
39
+ it { expect{$account.delete_playlists params}.to change{$account.playlists.count}.by(-1) }
41
40
  end
42
41
 
43
42
  describe 'update a playlist' do
44
- before { @playlist = account.create_playlist params }
43
+ before { @playlist = $account.create_playlist params }
45
44
  after { @playlist.delete }
46
45
 
47
46
  context 'changes the attributes that are specified to be updated' do
@@ -1,12 +1,10 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/models/video'
3
3
 
4
- describe Yt::Associations::Ratings, scenario: :device_app do
5
- let(:account) { Yt.configuration.account }
6
-
4
+ describe Yt::Associations::Ratings, :device_app do
7
5
  describe '#rating' do
8
6
  context 'given an existing video' do
9
- let(:video) { Yt::Video.new id: 'MESycYJytkU', auth: account }
7
+ let(:video) { Yt::Video.new id: 'MESycYJytkU', auth: $account }
10
8
 
11
9
  context 'that I like' do
12
10
  before { video.like }
@@ -3,27 +3,25 @@ require 'yt/associations/snippets'
3
3
  require 'yt/models/channel'
4
4
  require 'yt/models/video'
5
5
 
6
- describe Yt::Associations::Snippets, scenario: :device_app do
7
- let(:account) { Yt.configuration.account }
8
-
6
+ describe Yt::Associations::Snippets, :device_app do
9
7
  describe '#snippet' do
10
8
  context 'given an existing video resource' do
11
- let(:video) { Yt::Video.new id: 'MESycYJytkU', auth: account }
9
+ let(:video) { Yt::Video.new id: 'MESycYJytkU', auth: $account }
12
10
  it { expect(video.snippet).to be_a Yt::Snippet }
13
11
  end
14
12
 
15
13
  context 'given an unknown video resource' do
16
- let(:video) { Yt::Video.new id: 'not-a-video-id', auth: account }
14
+ let(:video) { Yt::Video.new id: 'not-a-video-id', auth: $account }
17
15
  it { expect{video.snippet}.to raise_error Yt::Errors::NoItems }
18
16
  end
19
17
 
20
18
  context 'given an existing channel resource' do
21
- let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: account }
19
+ let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: $account }
22
20
  it { expect(channel.snippet).to be_a Yt::Snippet }
23
21
  end
24
22
 
25
23
  context 'given an unknown channel resource' do
26
- let(:channel) { Yt::Channel.new id: 'not-a-channel-id', auth: account }
24
+ let(:channel) { Yt::Channel.new id: 'not-a-channel-id', auth: $account }
27
25
  it { expect{channel.snippet}.to raise_error Yt::Errors::NoItems }
28
26
  end
29
27
  end
@@ -4,12 +4,10 @@ require 'yt/models/channel'
4
4
  # NOTE: This test is slow because we *must* wait for some seconds between
5
5
  # subscribing and unsubscribing to a channel, otherwise YouTube will show
6
6
  # wrong (cached) data, such as a user is subscribed when he is not.
7
- describe Yt::Associations::Subscriptions, scenario: :device_app do
8
- let(:account) { Yt.configuration.account }
9
-
7
+ describe Yt::Associations::Subscriptions, :device_app do
10
8
  describe '#subscription' do
11
9
  context 'given an existing channel' do
12
- let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: account }
10
+ let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: $account }
13
11
 
14
12
  context 'that I am not subscribed to' do
15
13
  before { channel.unsubscribe }
@@ -1,13 +1,10 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/user_infos'
3
3
 
4
- describe Yt::Associations::UserInfos, scenario: :device_app do
5
- subject(:account) { Yt::Account.new attrs }
6
-
4
+ describe Yt::Associations::UserInfos, :device_app do
7
5
  describe '#user_info' do
8
6
  context 'given an existing account' do
9
- let(:account) { Yt.configuration.account }
10
- it { expect(account.user_info).to be_a Yt::UserInfo }
7
+ it { expect($account.user_info).to be_a Yt::UserInfo }
11
8
  end
12
9
 
13
10
  # Note: testing with an unknown account would fail before getting user info
@@ -1,12 +1,10 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/videos'
3
3
 
4
- describe Yt::Associations::Videos, scenario: :device_app do
5
- let(:account) { Yt.configuration.account }
6
-
4
+ describe Yt::Associations::Videos, :device_app do
7
5
  describe '#videos' do
8
6
  context 'given a channel with videos' do
9
- let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: account }
7
+ let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: $account }
10
8
  it { expect(channel.videos.count).to be > 0 }
11
9
  it { expect(channel.videos.first).to be_a Yt::Video }
12
10
  end
@@ -15,7 +13,7 @@ describe Yt::Associations::Videos, scenario: :device_app do
15
13
  # wrong channel ID starts with "UC" then it returns 0 results, otherwise
16
14
  # it ignores the channel filter and returns 100,000 results.
17
15
  context 'given an unknown channel starting with UC' do
18
- let(:channel) { Yt::Channel.new id: 'UC-not-a-channel', auth: account }
16
+ let(:channel) { Yt::Channel.new id: 'UC-not-a-channel', auth: $account }
19
17
  it { expect(channel.videos.count).to be 0 }
20
18
  end
21
19
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/details_sets'
3
3
 
4
- describe Yt::Associations::DetailsSets, scenario: :server_app do
4
+ describe Yt::Associations::DetailsSets, :server_app do
5
5
  subject(:video) { Yt::Video.new id: video_id }
6
6
 
7
7
  describe '#details_set' do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/associations/ids'
3
3
 
4
- describe Yt::Associations::Ids, scenario: :server_app do
4
+ describe Yt::Associations::Ids, :server_app do
5
5
  subject(:resource) { Yt::Resource.new url: url }
6
6
 
7
7
  describe '#id' do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'yt/models/playlist'
3
3
  require 'yt/models/playlist_item'
4
4
 
5
- describe Yt::Associations::PlaylistItems, scenario: :server_app do
5
+ describe Yt::Associations::PlaylistItems, :server_app do
6
6
  describe '#playlist_items' do
7
7
  subject(:playlist_items) { playlist.playlist_items }
8
8
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'yt/models/channel'
3
3
  require 'yt/models/playlist'
4
4
 
5
- describe Yt::Associations::Playlists, scenario: :server_app do
5
+ describe Yt::Associations::Playlists, :server_app do
6
6
  describe '#playlists' do
7
7
  subject(:playlists) { channel.playlists }
8
8