yt 0.32.4 → 0.33.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -4
- data/CHANGELOG.md +43 -2
- data/README.md +22 -33
- data/YOUTUBE_IT.md +4 -4
- data/bin/yt +2 -9
- data/lib/yt.rb +0 -1
- data/lib/yt/actions/list.rb +1 -1
- data/lib/yt/associations/has_reports.rb +9 -14
- data/lib/yt/collections/playlist_items.rb +10 -1
- data/lib/yt/collections/reports.rb +5 -7
- data/lib/yt/models/account.rb +21 -1
- data/lib/yt/models/asset.rb +10 -1
- data/lib/yt/models/channel.rb +2 -5
- data/lib/yt/models/content_owner.rb +20 -0
- data/lib/yt/models/match_policy.rb +4 -6
- data/lib/yt/models/playlist.rb +12 -2
- data/lib/yt/models/playlist_item.rb +8 -1
- data/lib/yt/models/resource.rb +69 -3
- data/lib/yt/models/statistics_set.rb +2 -1
- data/lib/yt/models/url.rb +2 -60
- data/lib/yt/models/video.rb +16 -3
- data/lib/yt/request.rb +6 -2
- data/lib/yt/version.rb +1 -1
- data/yt.gemspec +5 -2
- metadata +31 -169
- data/spec/collections/claims_spec.rb +0 -62
- data/spec/collections/comment_threads_spec.rb +0 -46
- data/spec/collections/playlist_items_spec.rb +0 -44
- data/spec/collections/playlists_spec.rb +0 -27
- data/spec/collections/policies_spec.rb +0 -30
- data/spec/collections/references_spec.rb +0 -30
- data/spec/collections/reports_spec.rb +0 -30
- data/spec/collections/subscriptions_spec.rb +0 -25
- data/spec/collections/videos_spec.rb +0 -43
- data/spec/constants/geography_spec.rb +0 -16
- data/spec/errors/forbidden_spec.rb +0 -10
- data/spec/errors/missing_auth_spec.rb +0 -24
- data/spec/errors/no_items_spec.rb +0 -10
- data/spec/errors/request_error_spec.rb +0 -44
- data/spec/errors/server_error_spec.rb +0 -10
- data/spec/errors/unauthorized_spec.rb +0 -10
- data/spec/models/account_spec.rb +0 -138
- data/spec/models/annotation_spec.rb +0 -180
- data/spec/models/asset_spec.rb +0 -32
- data/spec/models/channel_spec.rb +0 -127
- data/spec/models/claim_event_spec.rb +0 -62
- data/spec/models/claim_history_spec.rb +0 -27
- data/spec/models/claim_spec.rb +0 -223
- data/spec/models/comment_spec.rb +0 -40
- data/spec/models/comment_thread_spec.rb +0 -93
- data/spec/models/configuration_spec.rb +0 -44
- data/spec/models/content_detail_spec.rb +0 -52
- data/spec/models/content_owner_detail_spec.rb +0 -6
- data/spec/models/file_detail_spec.rb +0 -13
- data/spec/models/live_streaming_detail_spec.rb +0 -6
- data/spec/models/ownership_spec.rb +0 -59
- data/spec/models/player_spec.rb +0 -13
- data/spec/models/playlist_item_spec.rb +0 -120
- data/spec/models/playlist_spec.rb +0 -138
- data/spec/models/policy_rule_spec.rb +0 -63
- data/spec/models/policy_spec.rb +0 -41
- data/spec/models/rating_spec.rb +0 -12
- data/spec/models/reference_spec.rb +0 -249
- data/spec/models/request_spec.rb +0 -204
- data/spec/models/resource_spec.rb +0 -42
- data/spec/models/right_owner_spec.rb +0 -71
- data/spec/models/snippet_spec.rb +0 -13
- data/spec/models/statistics_set_spec.rb +0 -13
- data/spec/models/status_spec.rb +0 -13
- data/spec/models/subscription_spec.rb +0 -30
- data/spec/models/url_spec.rb +0 -78
- data/spec/models/video_category_spec.rb +0 -21
- data/spec/models/video_spec.rb +0 -669
- data/spec/requests/as_account/account_spec.rb +0 -143
- data/spec/requests/as_account/authentications_spec.rb +0 -127
- data/spec/requests/as_account/channel_spec.rb +0 -246
- data/spec/requests/as_account/channels_spec.rb +0 -18
- data/spec/requests/as_account/playlist_item_spec.rb +0 -55
- data/spec/requests/as_account/playlist_spec.rb +0 -218
- data/spec/requests/as_account/thumbnail.jpg +0 -0
- data/spec/requests/as_account/video.mp4 +0 -0
- data/spec/requests/as_account/video_spec.rb +0 -408
- data/spec/requests/as_content_owner/account_spec.rb +0 -29
- data/spec/requests/as_content_owner/advertising_options_set_spec.rb +0 -15
- data/spec/requests/as_content_owner/asset_spec.rb +0 -31
- data/spec/requests/as_content_owner/bulk_report_job_spec.rb +0 -19
- data/spec/requests/as_content_owner/channel_spec.rb +0 -1836
- data/spec/requests/as_content_owner/claim_history_spec.rb +0 -20
- data/spec/requests/as_content_owner/claim_spec.rb +0 -17
- data/spec/requests/as_content_owner/content_owner_spec.rb +0 -370
- data/spec/requests/as_content_owner/match_policy_spec.rb +0 -17
- data/spec/requests/as_content_owner/ownership_spec.rb +0 -25
- data/spec/requests/as_content_owner/playlist_spec.rb +0 -767
- data/spec/requests/as_content_owner/video_group_spec.rb +0 -112
- data/spec/requests/as_content_owner/video_spec.rb +0 -1211
- data/spec/requests/as_server_app/channel_spec.rb +0 -54
- data/spec/requests/as_server_app/comment_spec.rb +0 -22
- data/spec/requests/as_server_app/comment_thread_spec.rb +0 -27
- data/spec/requests/as_server_app/comment_threads_spec.rb +0 -41
- data/spec/requests/as_server_app/playlist_item_spec.rb +0 -30
- data/spec/requests/as_server_app/playlist_spec.rb +0 -33
- data/spec/requests/as_server_app/url_spec.rb +0 -94
- data/spec/requests/as_server_app/video_spec.rb +0 -60
- data/spec/requests/as_server_app/videos_spec.rb +0 -40
- data/spec/requests/unauthenticated/video_spec.rb +0 -14
- data/spec/spec_helper.rb +0 -20
- data/spec/support/fail_matcher.rb +0 -15
- data/spec/support/global_hooks.rb +0 -48
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/errors/server_error'
|
3
|
-
|
4
|
-
describe Yt::Errors::ServerError do
|
5
|
-
let(:msg) { %r{^A request to YouTube API caused an unexpected server error} }
|
6
|
-
|
7
|
-
describe '#exception' do
|
8
|
-
it { expect{raise Yt::Errors::ServerError}.to raise_error msg }
|
9
|
-
end
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/errors/unauthorized'
|
3
|
-
|
4
|
-
describe Yt::Errors::Unauthorized 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::Unauthorized}.to raise_error msg }
|
9
|
-
end
|
10
|
-
end
|
data/spec/models/account_spec.rb
DELETED
@@ -1,138 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/account'
|
3
|
-
|
4
|
-
describe Yt::Video do
|
5
|
-
subject(:account) { Yt::Account.new attrs }
|
6
|
-
|
7
|
-
describe '#id' do
|
8
|
-
context 'given a user info with an ID' do
|
9
|
-
let(:attrs) { {user_info: {"id"=>"103024385"}} }
|
10
|
-
it { expect(account.id).to eq '103024385' }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'given a user info without an ID' do
|
14
|
-
let(:attrs) { {user_info: {}} }
|
15
|
-
it { expect(account.id).to eq '' }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#email' do
|
20
|
-
context 'given a user info with an email' do
|
21
|
-
let(:attrs) { {user_info: {"email"=>"user@example.com"}} }
|
22
|
-
it { expect(account.email).to eq 'user@example.com' }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'given a user info without an email' do
|
26
|
-
let(:attrs) { {user_info: {}} }
|
27
|
-
it { expect(account.email).to eq '' }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#has_verified_email?' do
|
32
|
-
context 'given a user info with a verified email' do
|
33
|
-
let(:attrs) { {user_info: {"verified_email"=>true}} }
|
34
|
-
it { expect(account).to have_verified_email }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'given a user info without a verified email' do
|
38
|
-
let(:attrs) { {user_info: {"verified_email"=>false}} }
|
39
|
-
it { expect(account).not_to have_verified_email }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#name' do
|
44
|
-
context 'given a user info with a name' do
|
45
|
-
let(:attrs) { {user_info: {"name"=>"User Example"}} }
|
46
|
-
it { expect(account.name).to eq 'User Example' }
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'given a user info without a name' do
|
50
|
-
let(:attrs) { {user_info: {}} }
|
51
|
-
it { expect(account.name).to eq '' }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#given_name' do
|
56
|
-
context 'given a user info with a given name' do
|
57
|
-
let(:attrs) { {user_info: {"given_name"=>"User"}} }
|
58
|
-
it { expect(account.given_name).to eq 'User' }
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'given a user info without a given name' do
|
62
|
-
let(:attrs) { {user_info: {}} }
|
63
|
-
it { expect(account.given_name).to eq '' }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#family_name' do
|
68
|
-
context 'given a user info with a family name' do
|
69
|
-
let(:attrs) { {user_info: {"family_name"=>"Example"}} }
|
70
|
-
it { expect(account.family_name).to eq 'Example' }
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'given a user info without a family name' do
|
74
|
-
let(:attrs) { {user_info: {}} }
|
75
|
-
it { expect(account.family_name).to eq '' }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#profile_url' do
|
80
|
-
context 'given a user info with a link' do
|
81
|
-
let(:attrs) { {user_info: {"link"=>"https://plus.google.com/1234"}} }
|
82
|
-
it { expect(account.profile_url).to eq 'https://plus.google.com/1234' }
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'given a user info without a link' do
|
86
|
-
let(:attrs) { {user_info: {}} }
|
87
|
-
it { expect(account.profile_url).to eq '' }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '#avatar_url' do
|
92
|
-
context 'given a user info with a picture' do
|
93
|
-
let(:attrs) { {user_info: {"picture"=>"https://lh3.googleusercontent.com/photo.jpg"}} }
|
94
|
-
it { expect(account.avatar_url).to eq 'https://lh3.googleusercontent.com/photo.jpg' }
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'given a user info without a picture' do
|
98
|
-
let(:attrs) { {user_info: {}} }
|
99
|
-
it { expect(account.avatar_url).to eq '' }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe '#gender' do
|
104
|
-
context 'given a user info with a gender' do
|
105
|
-
let(:attrs) { {user_info: {"gender"=>"male"}} }
|
106
|
-
it { expect(account.gender).to eq 'male' }
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'given a user info without a gender' do
|
110
|
-
let(:attrs) { {user_info: {}} }
|
111
|
-
it { expect(account.gender).to eq '' }
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe '#locale' do
|
116
|
-
context 'given a user info with a locale' do
|
117
|
-
let(:attrs) { {user_info: {"locale"=>"en"}} }
|
118
|
-
it { expect(account.locale).to eq 'en' }
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'given a user info without a locale' do
|
122
|
-
let(:attrs) { {user_info: {}} }
|
123
|
-
it { expect(account.locale).to eq '' }
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe '#hd' do
|
128
|
-
context 'given a user info with a Google App domain' do
|
129
|
-
let(:attrs) { {user_info: {"hd"=>"example.com"}} }
|
130
|
-
it { expect(account.hd).to eq 'example.com' }
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'given a user info without a Google App domain' do
|
134
|
-
let(:attrs) { {user_info: {}} }
|
135
|
-
it { expect(account.hd).to eq '' }
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
@@ -1,180 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/annotation'
|
3
|
-
|
4
|
-
describe Yt::Annotation do
|
5
|
-
subject(:annotation) { Yt::Annotation.new data: Hash.from_xml(xml) }
|
6
|
-
|
7
|
-
describe '#above? and #below?' do
|
8
|
-
let(:xml) { %Q{
|
9
|
-
<segment>
|
10
|
-
<movingRegion type="rect">
|
11
|
-
<rectRegion d="0" h="17.7779998779" t="0:04.000" w="25.0" x="7.117000103" y="5.07000017166"/>
|
12
|
-
<rectRegion d="0" h="17.7779998779" t="0:05.000" w="25.0" x="7.117000103" y="5.07000017166"/>
|
13
|
-
</movingRegion>
|
14
|
-
</segment>
|
15
|
-
} }
|
16
|
-
|
17
|
-
context 'given an annotation located above N% of the video height' do
|
18
|
-
it { expect(annotation.above? 50).to be true }
|
19
|
-
it { expect(annotation.below? 50).to be_falsey }
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'given an annotation located below N% of the video height' do
|
23
|
-
it { expect(annotation.above? 5).to be_falsey }
|
24
|
-
it { expect(annotation.below? 5).to be true }
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'given an annotation without a single position' do
|
28
|
-
let(:xml) { %Q{
|
29
|
-
<segment>
|
30
|
-
<movingRegion type="rect">
|
31
|
-
<rectRegion d="0" h="17.7779998779" t="0:05.000" w="25.0" x="7.117000103" y="5.07000017166"/>
|
32
|
-
</movingRegion>
|
33
|
-
</segment>
|
34
|
-
} }
|
35
|
-
it { expect(annotation.above? 50).to be true }
|
36
|
-
it { expect(annotation.below? 50).to be_falsey }
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'given an annotation without explicit location' do
|
40
|
-
let(:xml) { '<segment></segment>' }
|
41
|
-
it { expect(annotation.above? 50).to be_falsey }
|
42
|
-
it { expect(annotation.below? 50).to be_falsey }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#text' do
|
47
|
-
context 'given an annotation with text' do
|
48
|
-
let(:xml) { '<TEXT>Hello, world!</TEXT>' }
|
49
|
-
it { expect(annotation.text).to eq 'Hello, world!' }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#has_link_to_subscribe?' do
|
54
|
-
context 'given an annotation with a link of class 5' do
|
55
|
-
let(:xml) { '<action type="openUrl"><url link_class="5"/></action>' }
|
56
|
-
it { expect(annotation).to have_link_to_subscribe }
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'given an annotation without a link of class 5' do
|
60
|
-
let(:xml) { '<action type="openUrl"><url link_class="3"/></action>' }
|
61
|
-
it { expect(annotation).not_to have_link_to_subscribe }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe '#has_link_to_video?' do
|
66
|
-
context 'given an annotation with a link of class 1' do
|
67
|
-
let(:xml) { '<action type="openUrl"><url link_class="1"/></action>' }
|
68
|
-
it { expect(annotation).to have_link_to_video }
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'given an annotation with a "featured video" invideo programming' do
|
72
|
-
let(:xml) { '<type>promotion</type>' }
|
73
|
-
it { expect(annotation).to have_link_to_video }
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'given an annotation without a link of class 1' do
|
77
|
-
let(:xml) { '<action type="openUrl"><url link_class="3"/></action>' }
|
78
|
-
it { expect(annotation).not_to have_link_to_video }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '#has_link_to_playlist?' do
|
83
|
-
context 'given an annotation with a link of class 2' do
|
84
|
-
let(:xml) { '<action type="openUrl"><url link_class="2"/></action>' }
|
85
|
-
it { expect(annotation).to have_link_to_playlist }
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'given an annotation with an embedded playlist link' do
|
89
|
-
let(:xml) { '<TEXT>https://www.youtube.com/watch?v=9bZkp7q19f0&list=LLxO1tY8h1AhOz0T4ENwmpow"</TEXT>' }
|
90
|
-
it { expect(annotation).to have_link_to_playlist }
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'given an annotation without a link of class 2' do
|
94
|
-
let(:xml) { '<action type="openUrl"><url link_class="3"/></action>' }
|
95
|
-
it { expect(annotation).not_to have_link_to_playlist }
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'given an annotation without text' do
|
99
|
-
let(:xml) { '<TEXT />' }
|
100
|
-
it { expect(annotation).not_to have_link_to_playlist }
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe '#has_link_to_same_window?' do
|
105
|
-
context 'given an annotation with a "current" target' do
|
106
|
-
let(:xml) { '<action type="openUrl"><url target="current"/></action>' }
|
107
|
-
it { expect(annotation).to have_link_to_same_window }
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'given an annotation without a "current" target' do
|
111
|
-
let(:xml) { '<action type="openUrl"><url target="new"/></action>' }
|
112
|
-
it { expect(annotation).not_to have_link_to_same_window }
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe '#has_invideo_programming?' do
|
117
|
-
context 'given an annotation with a "featured video" invideo programming' do
|
118
|
-
let(:xml) { '<type>promotion</type>' }
|
119
|
-
it { expect(annotation).to have_invideo_programming }
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'given an annotation with a "branding intro" invideo programming' do
|
123
|
-
let(:xml) { '<type>branding</type>' }
|
124
|
-
it { expect(annotation).to have_invideo_programming }
|
125
|
-
end
|
126
|
-
|
127
|
-
context 'given an annotation without an invideo programming' do
|
128
|
-
let(:xml) { '<segment></segment>' }
|
129
|
-
it { expect(annotation).not_to have_invideo_programming }
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe '#starts_after and #starts_before' do
|
134
|
-
context 'given an annotation with the first timestamp equal to 1 hour' do
|
135
|
-
let(:xml) { %Q{
|
136
|
-
<segment>
|
137
|
-
<movingRegion type="rect">
|
138
|
-
<rectRegion d="0" h="17.7779998779" t="01:00:01.000" w="25.0" x="7.117000103" y="5.07000017166"/>
|
139
|
-
<rectRegion d="0" h="17.7779998779" t="01:05:56.066" w="25.0" x="7.117000103" y="5.07000017166"/>
|
140
|
-
</movingRegion>
|
141
|
-
</segment>
|
142
|
-
} }
|
143
|
-
it { expect(annotation.starts_after? 3600).to be true }
|
144
|
-
it { expect(annotation.starts_after? 3610).to be_falsey }
|
145
|
-
it { expect(annotation.starts_before? 3600).to be_falsey }
|
146
|
-
it { expect(annotation.starts_before? 3610).to be true }
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'given an annotation without timestamps' do
|
150
|
-
let(:xml) { '<segment></segment>' }
|
151
|
-
it { expect(annotation.starts_after? 0).to be_nil }
|
152
|
-
it { expect(annotation.starts_before? 0).to be_nil }
|
153
|
-
end
|
154
|
-
|
155
|
-
context 'given an annotation with "never" as the timestamp' do
|
156
|
-
let(:xml) { %Q{
|
157
|
-
<segment>
|
158
|
-
<movingRegion type="rect">
|
159
|
-
<rectRegion h="6.0" t="never" w="25.0" x="7.0" y="5.0"/>
|
160
|
-
<rectRegion h="6.0" t="never" w="25.0" x="7.0" y="5.0"/>
|
161
|
-
</movingRegion>
|
162
|
-
</segment>
|
163
|
-
} }
|
164
|
-
it { expect(annotation.starts_after? 0).to be_nil }
|
165
|
-
it { expect(annotation.starts_before? 0).to be_nil }
|
166
|
-
end
|
167
|
-
|
168
|
-
context 'given an annotation with "0" as the timestamp' do
|
169
|
-
let(:xml) { %Q{
|
170
|
-
<segment>
|
171
|
-
<movingRegion type="rect">
|
172
|
-
<rectRegion h="6.0" t="0" w="25.0" x="7.0" y="5.0"/>
|
173
|
-
</movingRegion>
|
174
|
-
</segment>
|
175
|
-
} }
|
176
|
-
it { expect(annotation.starts_after? 10).to be_falsey }
|
177
|
-
it { expect(annotation.starts_before? 10).to be true }
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
data/spec/models/asset_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/asset'
|
3
|
-
|
4
|
-
describe Yt::Asset do
|
5
|
-
subject(:asset) { Yt::Asset.new data: data }
|
6
|
-
|
7
|
-
describe '#id' do
|
8
|
-
context 'given fetching a asset returns an id' do
|
9
|
-
let(:data) { {"id"=>"A123456789012345"} }
|
10
|
-
it { expect(asset.id).to eq 'A123456789012345' }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#type' do
|
15
|
-
context 'given fetching a asset returns an type' do
|
16
|
-
let(:data) { {"type"=>"web"} }
|
17
|
-
it { expect(asset.type).to eq 'web' }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#ownership_effective' do
|
22
|
-
context 'given fetching a asset returns an ownershipEffective' do
|
23
|
-
let(:data) {
|
24
|
-
{"ownershipEffective"=>{"kind"=>"youtubePartner#rightsOwnership",
|
25
|
-
"general"=>[{"ratio"=>100.0, "owner"=>"XOuN81q-MeEUVrsiZeK1lQ", "type"=>"exclude"}]}}
|
26
|
-
}
|
27
|
-
it { expect(asset.ownership_effective).to be_a Yt::Ownership }
|
28
|
-
it { expect(asset.ownership_effective.general_owners.first).to be_a Yt::RightOwner }
|
29
|
-
it { expect(asset.ownership_effective.general_owners.first.owner).to eq "XOuN81q-MeEUVrsiZeK1lQ" }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/models/channel_spec.rb
DELETED
@@ -1,127 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/channel'
|
3
|
-
|
4
|
-
describe Yt::Channel do
|
5
|
-
subject(:channel) { Yt::Channel.new attrs }
|
6
|
-
|
7
|
-
describe '#title' do
|
8
|
-
context 'given a snippet with a title' do
|
9
|
-
let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
|
10
|
-
it { expect(channel.title).to eq 'Fullscreen' }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'given a snippet without a title' do
|
14
|
-
let(:attrs) { {snippet: {}} }
|
15
|
-
it { expect(channel.title).to eq '' }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#description' do
|
20
|
-
context 'given a snippet with a description' do
|
21
|
-
let(:attrs) { {snippet: {"description"=>"A cool channel."}} }
|
22
|
-
it { expect(channel.description).to eq 'A cool channel.' }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'given a snippet without a description' do
|
26
|
-
let(:attrs) { {snippet: {}} }
|
27
|
-
it { expect(channel.description).to eq '' }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#thumbnail_url' do
|
32
|
-
context 'given a snippet with thumbnails' do
|
33
|
-
let(:attrs) { {snippet: {"thumbnails"=>{
|
34
|
-
"default"=>{"url"=> "http://example.com/88x88.jpg"},
|
35
|
-
"medium"=>{"url"=> "http://example.com/240x240.jpg"},
|
36
|
-
}}} }
|
37
|
-
it { expect(channel.thumbnail_url).to eq 'http://example.com/88x88.jpg' }
|
38
|
-
it { expect(channel.thumbnail_url 'default').to eq 'http://example.com/88x88.jpg' }
|
39
|
-
it { expect(channel.thumbnail_url :default).to eq 'http://example.com/88x88.jpg' }
|
40
|
-
it { expect(channel.thumbnail_url :medium).to eq 'http://example.com/240x240.jpg' }
|
41
|
-
it { expect(channel.thumbnail_url :high).to be_nil }
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'given a snippet without thumbnails' do
|
45
|
-
let(:attrs) { {snippet: {}} }
|
46
|
-
it { expect(channel.thumbnail_url).to be_nil }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#published_at' do
|
51
|
-
context 'given a snippet with a timestamp' do
|
52
|
-
let(:attrs) { {snippet: {"publishedAt"=>"2014-04-22T19:14:49.000Z"}} }
|
53
|
-
it { expect(channel.published_at.year).to be 2014 }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#comment_count' do
|
58
|
-
context 'given a video with comments' do
|
59
|
-
let(:attrs) { {statistics: {"commentCount"=>"33"}} }
|
60
|
-
it { expect(channel.comment_count).to be 33 }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe '#video_count' do
|
65
|
-
context 'given a video with videos' do
|
66
|
-
let(:attrs) { {statistics: {"videoCount"=>"42"}} }
|
67
|
-
it { expect(channel.video_count).to be 42 }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '#subscriber_count' do
|
72
|
-
context 'given a video with subscribers' do
|
73
|
-
let(:attrs) { {statistics: {"subscriberCount"=>"12"}} }
|
74
|
-
it { expect(channel.subscriber_count).to be 12 }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#subscriber_count_visible?' do
|
79
|
-
context 'given a video with publicly visible subscribers' do
|
80
|
-
let(:attrs) { {statistics: {"hiddenSubscriberCount"=>false}} }
|
81
|
-
it { expect(channel).to be_subscriber_count_visible }
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'given a video with hidden subscribers' do
|
85
|
-
let(:attrs) { {statistics: {"hiddenSubscriberCount"=>true}} }
|
86
|
-
it { expect(channel).not_to be_subscriber_count_visible }
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe '#content_owner' do
|
91
|
-
context 'given a content_owner_detail with a content owner' do
|
92
|
-
let(:attrs) { {content_owner_details: {"contentOwner"=>"FullScreen"}} }
|
93
|
-
it { expect(channel.content_owner).to eq 'FullScreen' }
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'given a content_owner_detail without a content owner' do
|
97
|
-
let(:attrs) { {content_owner_details: {}} }
|
98
|
-
it { expect(channel.content_owner).to be_nil }
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#linked_at' do
|
103
|
-
context 'given a content_owner_detail with a timeLinked' do
|
104
|
-
let(:attrs) { {content_owner_details: {"timeLinked"=>"2014-04-22T19:14:49.000Z"}} }
|
105
|
-
it { expect(channel.linked_at.year).to be 2014 }
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'given a content_owner_detail with a timeLinked' do
|
109
|
-
let(:attrs) { {content_owner_details: {}} }
|
110
|
-
it { expect(channel.linked_at).to be_nil }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#snippet' do
|
115
|
-
context 'given fetching a channel returns a snippet' do
|
116
|
-
let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
|
117
|
-
it { expect(channel.snippet).to be_a Yt::Snippet }
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe '#status' do
|
122
|
-
context 'given fetching a channel returns a status' do
|
123
|
-
let(:attrs) { {status: {"privacyStatus"=>"public"}} }
|
124
|
-
it { expect(channel.status).to be_a Yt::Status }
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|