yt 0.32.6 → 0.33.0
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 +19 -0
- data/README.md +22 -32
- data/YOUTUBE_IT.md +4 -4
- data/lib/yt.rb +0 -1
- data/lib/yt/associations/has_reports.rb +9 -14
- data/lib/yt/collections/reports.rb +5 -7
- data/lib/yt/models/resource.rb +69 -3
- data/lib/yt/models/url.rb +2 -60
- 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 -1223
- 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
data/spec/models/request_spec.rb
DELETED
@@ -1,204 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/request'
|
3
|
-
|
4
|
-
|
5
|
-
describe Yt::Request do
|
6
|
-
subject(:request) { Yt::Request.new host: 'example.com' }
|
7
|
-
let(:response) { response_class.new nil, nil, nil }
|
8
|
-
let(:response_body) { }
|
9
|
-
|
10
|
-
describe '#run' do
|
11
|
-
context 'given a request that returns' do
|
12
|
-
before { allow(response).to receive(:body).and_return response_body }
|
13
|
-
before { expect(Net::HTTP).to receive(:start).once.and_return response }
|
14
|
-
|
15
|
-
context 'a success code 2XX' do
|
16
|
-
let(:response_class) { Net::HTTPOK }
|
17
|
-
|
18
|
-
it { expect{request.run}.not_to fail }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'an error code 5XX' do
|
22
|
-
let(:response_class) { Net::HTTPServerError }
|
23
|
-
let(:retry_response) { retry_response_class.new nil, nil, nil }
|
24
|
-
before { allow(retry_response).to receive(:body) }
|
25
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
26
|
-
|
27
|
-
context 'every time' do
|
28
|
-
let(:retry_response_class) { Net::HTTPServerError }
|
29
|
-
|
30
|
-
it { expect{request.run}.to fail }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'but returns a success code 2XX the second time' do
|
34
|
-
let(:retry_response_class) { Net::HTTPOK }
|
35
|
-
|
36
|
-
it { expect{request.run}.not_to fail }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'an error code 403 with a "quota exceeded message"' do
|
41
|
-
let(:response_class) { Net::HTTPForbidden }
|
42
|
-
let(:retry_response) { retry_response_class.new nil, nil, nil }
|
43
|
-
let(:response_body) { "{\n \"error\": {\n \"errors\": [\n {\n \"domain\": \"youtube.quota\",\n \"reason\": \"quotaExceeded\",\n \"message\": \"The request cannot be completed because you have exceeded your \\u003ca href=\\\"/youtube/v3/getting-started#quota\\\"\\u003equota\\u003c/a\\u003e.\"\n }\n ],\n \"code\": 403,\n \"message\": \"The request cannot be completed because you have exceeded your \\u003ca href=\\\"/youtube/v3/getting-started#quota\\\"\\u003equota\\u003c/a\\u003e.\"\n }\n}\n" }
|
44
|
-
before { allow(retry_response).to receive(:body) }
|
45
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
46
|
-
|
47
|
-
context 'every time' do
|
48
|
-
let(:retry_response_class) { Net::HTTPForbidden }
|
49
|
-
|
50
|
-
it { expect{request.run}.to fail }
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'but returns a success code 2XX the second time' do
|
54
|
-
let(:retry_response_class) { Net::HTTPOK }
|
55
|
-
|
56
|
-
it { expect{request.run}.not_to fail }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'an error code 401' do
|
61
|
-
let(:response_class) { Net::HTTPUnauthorized }
|
62
|
-
|
63
|
-
it { expect{request.run}.to fail }
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'any other non-2XX error code' do
|
67
|
-
let(:response_class) { Net::HTTPNotFound }
|
68
|
-
|
69
|
-
it { expect{request.run}.to fail }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# TODO: clean up the following tests, removing repetitions
|
74
|
-
context 'given a request that raises' do
|
75
|
-
before { expect(Net::HTTP).to receive(:start).once.and_raise http_error }
|
76
|
-
|
77
|
-
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
78
|
-
# being unavailable once in a while, and therefore causing Net::HTTP to
|
79
|
-
# fail, although retrying after some seconds works.
|
80
|
-
context 'an OpenSSL::SSL::SSLError' do
|
81
|
-
let(:http_error) { OpenSSL::SSL::SSLError.new }
|
82
|
-
|
83
|
-
context 'every time' do
|
84
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
|
85
|
-
|
86
|
-
it { expect{request.run}.to fail }
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'but works the second time' do
|
90
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
91
|
-
before { allow(retry_response).to receive(:body) }
|
92
|
-
let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
|
93
|
-
|
94
|
-
it { expect{request.run}.not_to fail }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
99
|
-
# being unavailable once in a while, and therefore causing Net::HTTP to
|
100
|
-
# fail, although retrying after some seconds works.
|
101
|
-
context 'an Errno::ETIMEDOUT' do
|
102
|
-
let(:http_error) { Errno::ETIMEDOUT.new }
|
103
|
-
|
104
|
-
context 'every time' do
|
105
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
|
106
|
-
|
107
|
-
it { expect{request.run}.to fail }
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'but works the second time' do
|
111
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
112
|
-
before { allow(retry_response).to receive(:body) }
|
113
|
-
let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
|
114
|
-
|
115
|
-
it { expect{request.run}.not_to fail }
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
120
|
-
# being unavailable once in a while, and therefore causing Net::HTTP to
|
121
|
-
# fail, although retrying after some seconds works.
|
122
|
-
context 'an Errno::ENETUNREACH' do
|
123
|
-
let(:http_error) { Errno::ENETUNREACH.new }
|
124
|
-
|
125
|
-
context 'every time' do
|
126
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
|
127
|
-
|
128
|
-
it { expect{request.run}.to fail }
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'but works the second time' do
|
132
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
133
|
-
before { allow(retry_response).to receive(:body) }
|
134
|
-
let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
|
135
|
-
|
136
|
-
it { expect{request.run}.not_to fail }
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
141
|
-
# being unavailable once in a while, and therefore causing Net::HTTP to
|
142
|
-
# fail, although retrying after some seconds works.
|
143
|
-
context 'an Errno::EHOSTUNREACH' do
|
144
|
-
let(:http_error) { Errno::EHOSTUNREACH.new }
|
145
|
-
|
146
|
-
context 'every time' do
|
147
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
|
148
|
-
|
149
|
-
it { expect{request.run}.to fail }
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'but works the second time' do
|
153
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
154
|
-
before { allow(retry_response).to receive(:body) }
|
155
|
-
let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
|
156
|
-
|
157
|
-
it { expect{request.run}.not_to fail }
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
162
|
-
# being unavailable once in a while, and therefore causing Net::HTTP to
|
163
|
-
# fail, although retrying after some seconds works.
|
164
|
-
context 'an OpenSSL::SSL::SSLErrorWaitReadable', ruby21: true do
|
165
|
-
let(:http_error) { OpenSSL::SSL::SSLErrorWaitReadable.new }
|
166
|
-
|
167
|
-
context 'every time' do
|
168
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
|
169
|
-
|
170
|
-
it { expect{request.run}.to fail }
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'but works the second time' do
|
174
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
175
|
-
before { allow(retry_response).to receive(:body) }
|
176
|
-
let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
|
177
|
-
|
178
|
-
it { expect{request.run}.not_to fail }
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
183
|
-
# being unavailable once in a while, and therefore causing Net::HTTP to
|
184
|
-
# fail, although retrying after some seconds works.
|
185
|
-
context 'a SocketError', ruby21: true do
|
186
|
-
let(:http_error) { SocketError.new }
|
187
|
-
|
188
|
-
context 'every time' do
|
189
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_raise http_error }
|
190
|
-
|
191
|
-
it { expect{request.run}.to fail }
|
192
|
-
end
|
193
|
-
|
194
|
-
context 'but works the second time' do
|
195
|
-
before { expect(Net::HTTP).to receive(:start).at_least(:once).and_return retry_response }
|
196
|
-
before { allow(retry_response).to receive(:body) }
|
197
|
-
let(:retry_response) { Net::HTTPOK.new nil, nil, nil }
|
198
|
-
|
199
|
-
it { expect{request.run}.not_to fail }
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/resource'
|
3
|
-
|
4
|
-
describe Yt::Resource do
|
5
|
-
subject(:resource) { Yt::Resource.new attrs }
|
6
|
-
|
7
|
-
describe '#public?' do
|
8
|
-
context 'given fetching a status returns privacyStatus "public"' do
|
9
|
-
let(:attrs) { {status: {"privacyStatus"=>"public"}} }
|
10
|
-
it { expect(resource).to be_public }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'given fetching a status does not return privacyStatus "public"' do
|
14
|
-
let(:attrs) { {status: {}} }
|
15
|
-
it { expect(resource).not_to be_public }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#private?' do
|
20
|
-
context 'given fetching a status returns privacyStatus "private"' do
|
21
|
-
let(:attrs) { {status: {"privacyStatus"=>"private"}} }
|
22
|
-
it { expect(resource).to be_private }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'given fetching a status does not return privacyStatus "private"' do
|
26
|
-
let(:attrs) { {status: {}} }
|
27
|
-
it { expect(resource).not_to be_private }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#unlisted?' do
|
32
|
-
context 'given fetching a status returns privacyStatus "unlisted"' do
|
33
|
-
let(:attrs) { {status: {"privacyStatus"=>"unlisted"}} }
|
34
|
-
it { expect(resource).to be_unlisted }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'given fetching a status does not return privacyStatus "unlisted"' do
|
38
|
-
let(:attrs) { {status: {}} }
|
39
|
-
it { expect(resource).not_to be_unlisted }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/right_owner'
|
3
|
-
|
4
|
-
describe Yt::RightOwner do
|
5
|
-
subject(:right_owner) { Yt::RightOwner.new data: data }
|
6
|
-
let(:data) { {} }
|
7
|
-
|
8
|
-
describe '#ratio' do
|
9
|
-
context 'given fetching an owner returns a ratio' do
|
10
|
-
let(:data) { {"ratio"=>"20.0"} }
|
11
|
-
it { expect(right_owner.ratio).to eq 20 }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#owner' do
|
16
|
-
context 'given fetching an owner returns an owner name' do
|
17
|
-
let(:data) { {"owner"=>"FullScreen"} }
|
18
|
-
it { expect(right_owner.owner).to eq 'FullScreen' }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#owner' do
|
23
|
-
context 'given fetching an owner returns a publisher name' do
|
24
|
-
let(:data) { {"publisher"=>"Third Party"} }
|
25
|
-
it { expect(right_owner.publisher).to eq 'Third Party' }
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'given fetching an owner does not return a publisher name' do
|
29
|
-
it { expect(right_owner.publisher).to be_nil }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#included_territories' do
|
34
|
-
context 'given fetching an owner returns included territories' do
|
35
|
-
let(:data) { {"type"=>"include", "territories"=>["US", "CA"]} }
|
36
|
-
it { expect(right_owner.included_territories).to eq %w(US CA) }
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'given fetching an owner does not return included territories' do
|
40
|
-
it { expect(right_owner.included_territories).to be_nil }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#excluded_territories' do
|
45
|
-
context 'given fetching an owner returns excluded territories' do
|
46
|
-
let(:data) { {"type"=>"exclude", "territories"=>["US", "CA"]} }
|
47
|
-
it { expect(right_owner.excluded_territories).to eq %w(US CA) }
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'given fetching an owner does not return excluded territories' do
|
51
|
-
it { expect(right_owner.excluded_territories).to be_nil }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#everywhere?' do
|
56
|
-
context 'given fetching an owner returns zero excluded territories' do
|
57
|
-
let(:data) { {"type"=>"exclude", "territories"=>[]} }
|
58
|
-
it { expect(right_owner).to be_everywhere }
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'given fetching an owner returns no excluded territories' do
|
62
|
-
let(:data) { {"type"=>"exclude"} }
|
63
|
-
it { expect(right_owner).to be_everywhere }
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'given fetching an owner returns included territories' do
|
67
|
-
let(:data) { {"type"=>"include", "territories"=>[]} }
|
68
|
-
it { expect(right_owner).not_to be_everywhere }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/spec/models/snippet_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/snippet'
|
3
|
-
|
4
|
-
describe Yt::Snippet do
|
5
|
-
subject(:snippet) { Yt::Snippet.new data: data }
|
6
|
-
|
7
|
-
describe '#data' do
|
8
|
-
let(:data) { {"key"=>"value"} }
|
9
|
-
specify 'returns the data the snippet was initialized with' do
|
10
|
-
expect(snippet.data).to eq data
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/statistics_set'
|
3
|
-
|
4
|
-
describe Yt::StatisticsSet do
|
5
|
-
subject(:statistics_set) { Yt::StatisticsSet.new data: data }
|
6
|
-
|
7
|
-
describe '#data' do
|
8
|
-
let(:data) { {"key"=>"value"} }
|
9
|
-
specify 'returns the data the statistics set was initialized with' do
|
10
|
-
expect(statistics_set.data).to eq data
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/spec/models/status_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/status'
|
3
|
-
|
4
|
-
describe Yt::Status do
|
5
|
-
subject(:status) { Yt::Status.new data: data }
|
6
|
-
|
7
|
-
describe '#data' do
|
8
|
-
let(:data) { {"key"=>"value"} }
|
9
|
-
specify 'returns the data the status was initialized with' do
|
10
|
-
expect(status.data).to eq data
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/subscription'
|
3
|
-
|
4
|
-
describe Yt::Subscription do
|
5
|
-
subject(:subscription) { Yt::Subscription.new id: id }
|
6
|
-
|
7
|
-
describe '#exists?' do
|
8
|
-
context 'given a subscription with an id' do
|
9
|
-
let(:id) { 'CBl6OoF0BpiV' }
|
10
|
-
it { expect(subscription).to exist }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'given a subscription without an id' do
|
14
|
-
let(:id) { nil }
|
15
|
-
it { expect(subscription).not_to exist }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#delete' do
|
20
|
-
let(:id) { 'CBl6OoF0BpiV' }
|
21
|
-
before { expect(subscription).to behave }
|
22
|
-
|
23
|
-
context 'given an existing subscription' do
|
24
|
-
let(:behave) { receive(:do_delete).and_yield }
|
25
|
-
|
26
|
-
it { expect(subscription.delete).to be true }
|
27
|
-
it { expect{subscription.delete}.to change{subscription.exists?} }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/models/url_spec.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/url'
|
3
|
-
|
4
|
-
describe Yt::URL do
|
5
|
-
subject(:url) { Yt::URL.new text }
|
6
|
-
|
7
|
-
context 'given a YouTube playlist URL' do
|
8
|
-
let(:text) { "https://www.youtube.com/playlist?list=#{id}" }
|
9
|
-
|
10
|
-
describe 'works with existing playlists' do
|
11
|
-
let(:id) { 'LLxO1tY8h1AhOz0T4ENwmpow' }
|
12
|
-
it {expect(url.id).to eq id }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'works with unknown playlists' do
|
16
|
-
let(:id) { 'PL12--not-a-playlist' }
|
17
|
-
it {expect(url.id).to eq id }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'given a YouTube video URL' do
|
22
|
-
let(:text) { "https://www.youtube.com/watch?v=#{id}" }
|
23
|
-
|
24
|
-
describe 'works with existing videos' do
|
25
|
-
let(:id) { 'gknzFj_0vvY' }
|
26
|
-
it {expect(url.id).to eq id }
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'works with unknown videos' do
|
30
|
-
let(:id) { 'abc123abc12' }
|
31
|
-
it {expect(url.id).to eq id }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'given a YouTube channel URL in the ID form' do
|
36
|
-
let(:text) { "https://www.youtube.com/channel/#{id}" }
|
37
|
-
|
38
|
-
describe 'works with existing channels' do
|
39
|
-
let(:id) { 'UC4lU5YG9QDgs0X2jdnt7cdQ' }
|
40
|
-
it {expect(url.id).to eq id }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'works with unknown channels' do
|
44
|
-
let(:id) { 'UC-not-an-actual-channel' }
|
45
|
-
it {expect(url.id).to eq id }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'given an existing YouTube channel' do
|
50
|
-
let(:text) { 'youtube.com/channel/UCxO1tY8h1AhOz0T4ENwmpow' }
|
51
|
-
it {expect(url.kind).to eq :channel }
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'given an existing YouTube video' do
|
55
|
-
let(:text) { 'youtube.com/watch?v=gknzFj_0vvY' }
|
56
|
-
it {expect(url.kind).to eq :video }
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'given an existing YouTube playlist' do
|
60
|
-
let(:text) { 'youtube.com/playlist?list=LLxO1tY8h1AhOz0T4ENwmpow' }
|
61
|
-
it {expect(url.kind).to eq :playlist }
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'given an unknown YouTube channel URL' do
|
65
|
-
let(:text) { 'youtube.com/channel/UC-too-short-to-be-an-id' }
|
66
|
-
it {expect(url.kind).to eq :channel }
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'given an unknown YouTube video URL' do
|
70
|
-
let(:text) { 'youtu.be/not-an-id' }
|
71
|
-
it {expect(url.kind).to eq :unknown }
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'given an unknown text' do
|
75
|
-
let(:text) { 'not-really-anything---' }
|
76
|
-
it {expect(url.kind).to eq :unknown }
|
77
|
-
end
|
78
|
-
end
|