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
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/channel'
|
3
|
-
|
4
|
-
describe Yt::Channel, :server_app do
|
5
|
-
subject(:channel) { Yt::Channel.new attrs }
|
6
|
-
|
7
|
-
context 'given an existing channel ID' do
|
8
|
-
let(:attrs) { {id: 'UCAmh1DexLGcMtDlzMCIxo4w'} }
|
9
|
-
|
10
|
-
it 'returns valid snippet data' do
|
11
|
-
expect(channel.snippet).to be_a Yt::Snippet
|
12
|
-
expect(channel.title).to be_a String
|
13
|
-
expect(channel.description).to be_a String
|
14
|
-
expect(channel.thumbnail_url).to be_a String
|
15
|
-
expect(channel.published_at).to be_a Time
|
16
|
-
end
|
17
|
-
|
18
|
-
it { expect(channel.status).to be_a Yt::Status }
|
19
|
-
it { expect(channel.statistics_set).to be_a Yt::StatisticsSet }
|
20
|
-
it { expect(channel.videos).to be_a Yt::Collections::Videos }
|
21
|
-
it { expect(channel.videos.first).to be_a Yt::Video }
|
22
|
-
it { expect(channel.playlists).to be_a Yt::Collections::Playlists }
|
23
|
-
it { expect(channel.playlists.first).to be_a Yt::Playlist }
|
24
|
-
it { expect(channel.related_playlists).to be_a Yt::Collections::Playlists }
|
25
|
-
it { expect(channel.related_playlists.first).to be_a Yt::Playlist }
|
26
|
-
|
27
|
-
specify 'with a public list of subscriptions' do
|
28
|
-
expect(channel.subscribed_channels.first).to be_a Yt::Channel
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'with a hidden list of subscriptions' do
|
32
|
-
let(:attrs) { {id: 'UCZDZGN_73I019o6UYD2-4bg'} }
|
33
|
-
it { expect{channel.subscribed_channels.size}.to raise_error Yt::Errors::Forbidden }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'given an unknown channel ID' do
|
38
|
-
let(:attrs) { {id: 'not-a-channel-id'} }
|
39
|
-
|
40
|
-
it { expect{channel.snippet}.to raise_error Yt::Errors::NoItems }
|
41
|
-
it { expect{channel.status}.to raise_error Yt::Errors::NoItems }
|
42
|
-
it { expect{channel.statistics_set}.to raise_error Yt::Errors::NoItems }
|
43
|
-
|
44
|
-
describe 'starting with UC' do
|
45
|
-
let(:attrs) { {id: 'UC-not-a-channel-id'} }
|
46
|
-
|
47
|
-
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
48
|
-
# returns 0 results if the name of an unknown channel starts with UC, but
|
49
|
-
# returning 100,000 results otherwise (ignoring the channel filter).
|
50
|
-
it { expect(channel.videos.count).to be_zero }
|
51
|
-
it { expect(channel.videos.size).to be_zero }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/comment'
|
3
|
-
|
4
|
-
describe Yt::Comment, :server_app do
|
5
|
-
subject(:comment) { Yt::Comment.new attrs }
|
6
|
-
|
7
|
-
context 'given an existing comment (non-reply) ID' do
|
8
|
-
let(:attrs) { {id: 'z13kc1bxpp22hzaxr04cd1kreurbjja41q00k'} }
|
9
|
-
|
10
|
-
it { expect(comment.parent_id).to be_nil }
|
11
|
-
it { expect(comment.text_display).to be_a String }
|
12
|
-
it { expect(comment.author_display_name).to be_a String }
|
13
|
-
it { expect(comment.like_count).to be_a Integer }
|
14
|
-
it { expect(comment.updated_at).to be_a Time }
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'given an existing comment (reply) ID' do
|
18
|
-
let(:attrs) { {id: 'z13kc1bxpp22hzaxr04cd1kreurbjja41q00k.1458679991141996'} }
|
19
|
-
|
20
|
-
it { expect(comment.parent_id).to be_a String }
|
21
|
-
end
|
22
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/comment_thread'
|
3
|
-
require 'yt/models/comment'
|
4
|
-
|
5
|
-
describe Yt::CommentThread, :server_app do
|
6
|
-
subject(:comment_thread) { Yt::CommentThread.new attrs }
|
7
|
-
|
8
|
-
context 'given an existing comment thread ID about a channel' do
|
9
|
-
let(:attrs) { {id: 'UgzzJVW75s5KrSaf0Ah4AaABAg'} }
|
10
|
-
|
11
|
-
it { expect(comment_thread.video_id).to be_nil }
|
12
|
-
it { expect(comment_thread.total_reply_count).to be_an Integer }
|
13
|
-
it { expect(comment_thread.can_reply?).to be true }
|
14
|
-
it { expect(comment_thread).to be_public }
|
15
|
-
|
16
|
-
it { expect(comment_thread.top_level_comment).to be_a Yt::Comment }
|
17
|
-
it { expect(comment_thread.text_display).not_to be_empty }
|
18
|
-
it { expect(comment_thread.author_display_name).not_to be_empty }
|
19
|
-
it { expect(comment_thread.updated_at).to be_a Time }
|
20
|
-
it { expect(comment_thread.like_count).to be_a Integer }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'given an comment thread ID about a video' do
|
24
|
-
let(:attrs) { {id: 'z134e1gyav3qt3nnr22phjeavv2zdfef0'} }
|
25
|
-
it { expect(comment_thread.video_id).to be_a String }
|
26
|
-
end
|
27
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'yt/collections/comment_threads'
|
4
|
-
require 'yt/models/video'
|
5
|
-
require 'yt/models/channel'
|
6
|
-
|
7
|
-
describe Yt::Collections::CommentThreads, :server_app do
|
8
|
-
context "without parent association", :ruby2 do
|
9
|
-
subject(:comment_threads) { Yt::Collections::CommentThreads.new }
|
10
|
-
|
11
|
-
specify 'without given any of id, videoId, channelId or allThreadsRelatedToChannelId param, raise request error', :ruby2 do
|
12
|
-
expect{ comment_threads.size }.to raise_error(Yt::Errors::RequestError)
|
13
|
-
end
|
14
|
-
|
15
|
-
specify 'with a id param, only return one comment thread' do
|
16
|
-
expect(comment_threads.where(id: 'z13zytsilxbexh30e233gdyyttngfjfz104').size).to eq 1
|
17
|
-
end
|
18
|
-
|
19
|
-
specify 'with a videoId param, returns comment threads for the video', focus: true do
|
20
|
-
expect(comment_threads.where(videoId: 'MsplPPW7tFo').size).to be > 0
|
21
|
-
end
|
22
|
-
|
23
|
-
specify 'with a channelId param, returns comment threads for the channel' do
|
24
|
-
expect(comment_threads.where(channelId: 'UC-lHJZR3Gqxm24_Vd_AJ5Yw').size).to be > 0
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with parent association", :ruby2 do
|
29
|
-
subject(:comment_threads) { Yt::Collections::CommentThreads.new parent: parent}
|
30
|
-
|
31
|
-
context "parent as video" do
|
32
|
-
let(:parent) { Yt::Models::Video.new id: 'MsplPPW7tFo' }
|
33
|
-
it { expect(comment_threads.size).to be > 0 }
|
34
|
-
end
|
35
|
-
|
36
|
-
context "parent as channel" do
|
37
|
-
let(:parent) { Yt::Models::Channel.new id: 'UC-lHJZR3Gqxm24_Vd_AJ5Yw' }
|
38
|
-
it { expect(comment_threads.size).to be > 0 }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/playlist_item'
|
3
|
-
|
4
|
-
describe Yt::PlaylistItem, :server_app do
|
5
|
-
subject(:item) { Yt::PlaylistItem.new id: id }
|
6
|
-
|
7
|
-
context 'given an existing playlist item' do
|
8
|
-
let(:id) { 'UExiai1JRGU2Zzh2c0FQT0RFci1xRUZjRERvWHhqRzhEVC41MjE1MkI0OTQ2QzJGNzNG' }
|
9
|
-
|
10
|
-
it 'returns valid snippet data' do
|
11
|
-
expect(item.snippet).to be_a Yt::Snippet
|
12
|
-
expect(item.title).to be_a String
|
13
|
-
expect(item.description).to be_a String
|
14
|
-
expect(item.thumbnail_url).to be_a String
|
15
|
-
expect(item.published_at).to be_a Time
|
16
|
-
expect(item.channel_id).to be_a String
|
17
|
-
expect(item.channel_title).to be_a String
|
18
|
-
expect(item.playlist_id).to be_a String
|
19
|
-
expect(item.position).to be_an Integer
|
20
|
-
expect(item.video_id).to be_a String
|
21
|
-
expect(item.video).to be_a Yt::Models::Video
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'given an unknown playlist item' do
|
26
|
-
let(:id) { 'not-a-playlist-item-id' }
|
27
|
-
|
28
|
-
it { expect{item.snippet}.to raise_error Yt::Errors::RequestError }
|
29
|
-
end
|
30
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/playlist'
|
3
|
-
|
4
|
-
describe Yt::Playlist, :server_app do
|
5
|
-
subject(:playlist) { Yt::Playlist.new attrs }
|
6
|
-
|
7
|
-
context 'given an existing playlist ID' do
|
8
|
-
let(:attrs) { {id: 'PLpjK416fmKwQ6Ene4GKRLICznoE1QFyt4'} }
|
9
|
-
|
10
|
-
it 'returns valid snippet data' do
|
11
|
-
expect(playlist.snippet).to be_a Yt::Snippet
|
12
|
-
expect(playlist.title).to be_a String
|
13
|
-
expect(playlist.description).to be_a String
|
14
|
-
expect(playlist.thumbnail_url).to be_a String
|
15
|
-
expect(playlist.published_at).to be_a Time
|
16
|
-
expect(playlist.tags).to be_an Array
|
17
|
-
expect(playlist.channel_id).to be_a String
|
18
|
-
expect(playlist.channel_title).to be_a String
|
19
|
-
expect(playlist.item_count).to be_an Integer
|
20
|
-
end
|
21
|
-
|
22
|
-
it { expect(playlist.status).to be_a Yt::Status }
|
23
|
-
it { expect(playlist.playlist_items).to be_a Yt::Collections::PlaylistItems }
|
24
|
-
it { expect(playlist.playlist_items.first).to be_a Yt::PlaylistItem }
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'given an unknown playlist' do
|
28
|
-
let(:attrs) { {id: 'not-a-playlist-id'} }
|
29
|
-
|
30
|
-
it { expect{playlist.snippet}.to raise_error Yt::Errors::NoItems }
|
31
|
-
it { expect{playlist.status}.to raise_error Yt::Errors::NoItems }
|
32
|
-
end
|
33
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/url'
|
3
|
-
|
4
|
-
describe Yt::URL, :server_app do
|
5
|
-
subject(:url) { Yt::URL.new text }
|
6
|
-
|
7
|
-
context 'given an existing YouTube channel URL' do
|
8
|
-
let(:text) { "youtube.com/channel/UCxO1tY8h1AhOz0T4ENwmpow" }
|
9
|
-
|
10
|
-
it {expect(url.resource).to be_a Yt::Channel }
|
11
|
-
it {expect(url.resource.title).to be }
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'given an existing YouTube video URL' do
|
15
|
-
let(:text) { "youtube.com/watch?v=gknzFj_0vvY" }
|
16
|
-
|
17
|
-
it {expect(url.resource).to be_a Yt::Video }
|
18
|
-
it {expect(url.resource.title).to be }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'given an unknown YouTube video URL' do
|
22
|
-
let(:text) { "youtu.be/invalid-id-" }
|
23
|
-
|
24
|
-
it {expect(url.resource).to be_a Yt::Video }
|
25
|
-
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'given an existing YouTube playlist URL' do
|
29
|
-
let(:text) { "youtube.com/playlist?list=PL-LeTutc9GRKD3yBDhnRF_yE8UTaQI5Jf" }
|
30
|
-
|
31
|
-
it {expect(url.resource).to be_a Yt::Playlist }
|
32
|
-
it {expect(url.resource.title).to be }
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'given an unknown YouTube playlist URL' do
|
36
|
-
let(:text) { "https://www.youtube.com/playlist?list=invalid-id-" }
|
37
|
-
|
38
|
-
it {expect(url.resource).to be_a Yt::Playlist }
|
39
|
-
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'given an unknown text' do
|
43
|
-
let(:text) { 'not-really-anything---' }
|
44
|
-
|
45
|
-
it {expect{url.resource}.to raise_error Yt::Errors::NoItems }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'given a YouTube channel URL in the name form' do
|
49
|
-
let(:text) { "http://www.youtube.com/#{name}" }
|
50
|
-
|
51
|
-
describe 'works when the name matches the custom URL' do
|
52
|
-
let(:name) { 'nbcsports' }
|
53
|
-
it {expect(url.id).to eq 'UCqZQlzSHbVJrwrn5XvzrzcA' }
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'works when the name matches the username' do
|
57
|
-
let(:name) { '2012NBCOlympics' }
|
58
|
-
it {expect(url.id).to eq 'UCqZQlzSHbVJrwrn5XvzrzcA' }
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'fails with unknown channels' do
|
62
|
-
let(:name) { 'not-an-actual-channel' }
|
63
|
-
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'given a YouTube channel URL in the custom form' do
|
68
|
-
let(:text) { "https://youtube.com/c/#{name}" }
|
69
|
-
|
70
|
-
describe 'works with existing channels' do
|
71
|
-
let(:name) { 'ogeeku' }
|
72
|
-
it {expect(url.id).to eq 'UC4nG_NxJniKoB-n6TLT2yaw' }
|
73
|
-
end
|
74
|
-
|
75
|
-
describe 'fails with unknown channels' do
|
76
|
-
let(:name) { 'not-an-actual-channel' }
|
77
|
-
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'given a YouTube channel URL in the username form' do
|
82
|
-
let(:text) { "youtube.com/user/#{name}" }
|
83
|
-
|
84
|
-
describe 'works with existing channels' do
|
85
|
-
let(:name) { 'ogeeku' }
|
86
|
-
it {expect(url.id).to eq 'UC4lU5YG9QDgs0X2jdnt7cdQ' }
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'fails with unknown channels' do
|
90
|
-
let(:name) { 'not-an-actual-channel' }
|
91
|
-
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/video'
|
3
|
-
require 'yt/collections/comment_threads'
|
4
|
-
|
5
|
-
describe Yt::Video, :server_app do
|
6
|
-
subject(:video) { Yt::Video.new attrs }
|
7
|
-
|
8
|
-
context 'given an existing video ID' do
|
9
|
-
let(:attrs) { {id: '9bZkp7q19f0'} }
|
10
|
-
|
11
|
-
it { expect(video.content_detail).to be_a Yt::ContentDetail }
|
12
|
-
|
13
|
-
it 'returns valid snippet data' do
|
14
|
-
expect(video.snippet).to be_a Yt::Snippet
|
15
|
-
expect(video.title).to be_a String
|
16
|
-
expect(video.description).to be_a String
|
17
|
-
expect(video.thumbnail_url).to be_a String
|
18
|
-
expect(video.published_at).to be_a Time
|
19
|
-
expect(video.tags).to be_an Array
|
20
|
-
expect(video.channel_id).to be_a String
|
21
|
-
expect(video.channel_title).to be_a String
|
22
|
-
expect(video.channel_url).to be_a String
|
23
|
-
expect(video.category_id).to be_a String
|
24
|
-
expect(video.live_broadcast_content).to be_a String
|
25
|
-
end
|
26
|
-
|
27
|
-
it { expect(video.status).to be_a Yt::Status }
|
28
|
-
it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'given an unknown video ID' do
|
32
|
-
let(:attrs) { {id: 'not-a-video-id'} }
|
33
|
-
|
34
|
-
it { expect{video.content_detail}.to raise_error Yt::Errors::NoItems }
|
35
|
-
it { expect{video.snippet}.to raise_error Yt::Errors::NoItems }
|
36
|
-
it { expect{video.status}.to raise_error Yt::Errors::NoItems }
|
37
|
-
it { expect{video.statistics_set}.to raise_error Yt::Errors::NoItems }
|
38
|
-
end
|
39
|
-
|
40
|
-
describe 'associations' do
|
41
|
-
let(:attrs) { {id: 'MsplPPW7tFo'} }
|
42
|
-
|
43
|
-
describe '#comment_threads' do
|
44
|
-
it { expect(video.comment_threads).to be_a Yt::Collections::CommentThreads }
|
45
|
-
it { expect(video.comment_threads.first.top_level_comment).to be_a Yt::Models::Comment }
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#comment_threads.each_cons' do
|
49
|
-
it {
|
50
|
-
comment_threads = []
|
51
|
-
video.comment_threads.each_cons(2).take_while do |items|
|
52
|
-
comment_threads += items
|
53
|
-
comment_threads.size < 6
|
54
|
-
end
|
55
|
-
expect(comment_threads.size).to be 6
|
56
|
-
}
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'yt/collections/videos'
|
4
|
-
|
5
|
-
describe Yt::Collections::Videos, :server_app do
|
6
|
-
subject(:videos) { Yt::Collections::Videos.new }
|
7
|
-
|
8
|
-
specify 'without :where conditions, returns all YouTube videos', :ruby2 do
|
9
|
-
expect(videos.size).to be > 100_000
|
10
|
-
end
|
11
|
-
|
12
|
-
specify 'with a query term, only returns some YouTube videos' do
|
13
|
-
expect(videos.where(q: 'Fullscreen CreatorPlatform', video_duration: :long).size).to be < 100_000
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'with a list of video IDs, only returns the videos matching those IDs' do
|
17
|
-
let(:video_id) { '9bZkp7q19f0' }
|
18
|
-
let(:videos_by_id) { videos.where id: "#{video_id},invalid" }
|
19
|
-
|
20
|
-
it { expect(videos_by_id.size).to be 1 }
|
21
|
-
it { expect(videos_by_id.first.id).to eq video_id }
|
22
|
-
end
|
23
|
-
|
24
|
-
specify 'with a chart parameter, only returns videos of that chart', :ruby2 do
|
25
|
-
expect(videos.where(chart: 'mostPopular').size).to be 200
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'with a list of parts' do
|
29
|
-
let(:video_id) { '9bZkp7q19f0' }
|
30
|
-
let(:part) { 'statistics,contentDetails' }
|
31
|
-
let(:video) { videos.where(id: '9bZkp7q19f0', part: part).first }
|
32
|
-
|
33
|
-
specify 'load ONLY the specified parts of the videos' do
|
34
|
-
expect(video.instance_variable_defined? :@snippet).to be false
|
35
|
-
expect(video.instance_variable_defined? :@status).to be false
|
36
|
-
expect(video.instance_variable_defined? :@statistics_set).to be true
|
37
|
-
expect(video.instance_variable_defined? :@content_detail).to be true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/video'
|
3
|
-
|
4
|
-
describe Yt::Video do
|
5
|
-
subject(:video) { Yt::Video.new id: id }
|
6
|
-
|
7
|
-
context 'given a public video with annotations' do
|
8
|
-
let(:id) { '9bZkp7q19f0' }
|
9
|
-
|
10
|
-
it { expect(video.annotations).to be_a Yt::Collections::Annotations }
|
11
|
-
it { expect(video.annotations.first).to be_a Yt::Annotation }
|
12
|
-
it { expect(video.annotations.size).to be > 0 }
|
13
|
-
end
|
14
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
SimpleCov.start
|
9
|
-
|
10
|
-
Dir['./spec/support/**/*.rb'].each {|f| require f}
|
11
|
-
|
12
|
-
RSpec.configure do |config|
|
13
|
-
config.order = 'random'
|
14
|
-
config.run_all_when_everything_filtered = false
|
15
|
-
# @note: Some tests might take too long to run on Ruby 1.9.3 which does not
|
16
|
-
# support "size" for Enumerator, so we are better off skipping them.
|
17
|
-
config.filter_run_excluding ruby2: true if RUBY_VERSION < '2'
|
18
|
-
# @note: See https://github.com/Fullscreen/yt/issues/103
|
19
|
-
config.filter_run_excluding ruby21: true if RUBY_VERSION < '2.1'
|
20
|
-
end
|