yt 0.32.6 → 0.33.4
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 +36 -0
- data/README.md +22 -33
- data/YOUTUBE_IT.md +4 -4
- data/lib/yt.rb +1 -1
- data/lib/yt/actions/list.rb +1 -1
- data/lib/yt/associations/has_reports.rb +9 -14
- data/lib/yt/collections/reports.rb +5 -7
- data/lib/yt/models/account.rb +13 -3
- data/lib/yt/models/channel.rb +19 -4
- data/lib/yt/models/resource.rb +74 -3
- data/lib/yt/models/status.rb +3 -1
- data/lib/yt/models/url.rb +2 -60
- data/lib/yt/models/video.rb +16 -1
- data/lib/yt/request.rb +7 -4
- data/lib/yt/version.rb +1 -1
- data/yt.gemspec +5 -2
- metadata +32 -170
- 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/comment_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/comment'
|
3
|
-
|
4
|
-
describe Yt::Comment do
|
5
|
-
subject(:comment) { Yt::Comment.new attrs }
|
6
|
-
|
7
|
-
describe '#snippet' do
|
8
|
-
context 'given fetching a comment returns a snippet' do
|
9
|
-
let(:attrs) { {snippet: {"videoId" => "12345"}} }
|
10
|
-
it { expect(comment.snippet).to be_a Yt::Snippet }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'attributes' do
|
15
|
-
examples = {
|
16
|
-
video_id: {with: 'xyz123', without: nil},
|
17
|
-
parent_id: {with: 'abc123', without: nil},
|
18
|
-
text_display: {with: 'awesome', without: nil},
|
19
|
-
author_display_name: {with: 'John', without: nil},
|
20
|
-
like_count: {with: 10, without: nil},
|
21
|
-
updated_at: {input: '2016-03-22T12:56:56.3Z', with: Time.parse('2016-03-22T12:56:56.3Z'), without: nil},
|
22
|
-
}
|
23
|
-
|
24
|
-
examples.each do |attr, cases|
|
25
|
-
describe "##{attr}" do
|
26
|
-
context "given a snippet with a #{attr}" do
|
27
|
-
let(:attrs) {
|
28
|
-
{snippet: {"#{attr.to_s.camelize(:lower)}" => cases[:input] || cases[:with]}}}
|
29
|
-
it { expect(comment.send(attr)).to eq cases[:with] }
|
30
|
-
end
|
31
|
-
|
32
|
-
context "given a snippet without a #{attr}" do
|
33
|
-
let(:attrs) { {snippet: {}} }
|
34
|
-
it { expect(comment.send(attr)).to eq cases[:without] }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/comment_thread'
|
3
|
-
|
4
|
-
describe Yt::CommentThread do
|
5
|
-
subject(:comment_thread) { Yt::CommentThread.new attrs }
|
6
|
-
|
7
|
-
describe '#snippet' do
|
8
|
-
context 'given fetching a comment thread returns a snippet' do
|
9
|
-
let(:attrs) { {snippet: {"videoId" => "12345"}} }
|
10
|
-
it { expect(comment_thread.snippet).to be_a Yt::Snippet }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#video_id' do
|
15
|
-
context 'given a snippet with a video id' do
|
16
|
-
let(:attrs) { {snippet: {"videoId"=>"12345"}} }
|
17
|
-
it { expect(comment_thread.video_id).to eq '12345' }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'given a snippet without a video id' do
|
21
|
-
let(:attrs) { {snippet: {}} }
|
22
|
-
it { expect(comment_thread.video_id).to be_nil }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#top_level_comment' do
|
27
|
-
context 'given a snippet with a top level comment' do
|
28
|
-
let(:attrs) { {snippet: {"topLevelComment"=> {}}} }
|
29
|
-
it { expect(comment_thread.top_level_comment).to be_a Yt::Comment }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'attributes from #top_level_comment delegations' do
|
34
|
-
context 'with values' do
|
35
|
-
let(:attrs) { {snippet: {"topLevelComment"=> {"id" => "xyz123", "snippet" => {
|
36
|
-
"textDisplay" => "funny video!",
|
37
|
-
"authorDisplayName" => "fullscreen",
|
38
|
-
"likeCount" => 99,
|
39
|
-
"updatedAt" => "2016-03-22T12:56:56.3Z"}}}} }
|
40
|
-
|
41
|
-
it { expect(comment_thread.top_level_comment.id).to eq 'xyz123' }
|
42
|
-
it { expect(comment_thread.text_display).to eq 'funny video!' }
|
43
|
-
it { expect(comment_thread.author_display_name).to eq 'fullscreen' }
|
44
|
-
it { expect(comment_thread.like_count).to eq 99 }
|
45
|
-
it { expect(comment_thread.updated_at).to eq Time.parse('2016-03-22T12:56:56.3Z') }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'without values' do
|
49
|
-
let(:attrs) { {snippet: {"topLevelComment"=> {"snippet" => {}}}} }
|
50
|
-
|
51
|
-
it { expect(comment_thread.text_display).to be_nil }
|
52
|
-
it { expect(comment_thread.author_display_name).to be_nil }
|
53
|
-
it { expect(comment_thread.like_count).to be_nil }
|
54
|
-
it { expect(comment_thread.updated_at).to be_nil }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#total_reply_count' do
|
59
|
-
context 'given a snippet with a total reply count' do
|
60
|
-
let(:attrs) { {snippet: {"totalReplyCount"=>1}} }
|
61
|
-
it { expect(comment_thread.total_reply_count).to eq 1 }
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'given a snippet without a total reply count' do
|
65
|
-
let(:attrs) { {snippet: {}} }
|
66
|
-
it { expect(comment_thread.total_reply_count).to be_nil }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#can_reply?' do
|
71
|
-
context 'given a snippet with canReply set' do
|
72
|
-
let(:attrs) { {snippet: {"canReply"=>true}} }
|
73
|
-
it { expect(comment_thread.can_reply?).to be true }
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'given a snippet without canReply set' do
|
77
|
-
let(:attrs) { {snippet: {}} }
|
78
|
-
it { expect(comment_thread.can_reply?).to be false }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '#is_public?' do
|
83
|
-
context 'given a snippet with isPublic set' do
|
84
|
-
let(:attrs) { {snippet: {"isPublic"=>true}} }
|
85
|
-
it { expect(comment_thread).to be_public }
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'given a snippet without isPublic set' do
|
89
|
-
let(:attrs) { {snippet: {}} }
|
90
|
-
it { expect(comment_thread).to_not be_public }
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Yt::Configuration do
|
4
|
-
subject(:config) { Yt::Configuration.new }
|
5
|
-
|
6
|
-
describe '#client_id' do
|
7
|
-
context 'without an environment variable YT_CLIENT_ID' do
|
8
|
-
before { ENV['YT_CLIENT_ID'] = nil }
|
9
|
-
it {expect(config.client_id).to be_nil }
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'given an environment variable YT_CLIENT_ID' do
|
13
|
-
let(:client_id) { '1234567890.apps.googleusercontent.com' }
|
14
|
-
before { ENV['YT_CLIENT_ID'] = client_id}
|
15
|
-
it {expect(config.client_id).to eq client_id }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#client_secret' do
|
20
|
-
context 'without an environment variable YT_CLIENT_SECRET' do
|
21
|
-
before { ENV['YT_CLIENT_SECRET'] = nil }
|
22
|
-
it {expect(config.client_secret).to be_nil }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'given an environment variable YT_CLIENT_SECRET' do
|
26
|
-
let(:client_secret) { '1234567890' }
|
27
|
-
before { ENV['YT_CLIENT_SECRET'] = client_secret}
|
28
|
-
it {expect(config.client_secret).to eq client_secret }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#api_key' do
|
33
|
-
context 'without an environment variable YT_API_KEY' do
|
34
|
-
before { ENV['YT_API_KEY'] = nil }
|
35
|
-
it {expect(config.api_key).to be_nil }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'given an environment variable YT_API_KEY' do
|
39
|
-
let(:api_key) { '123456789012345678901234567890' }
|
40
|
-
before { ENV['YT_API_KEY'] = api_key}
|
41
|
-
it {expect(config.api_key).to eq api_key }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/content_detail'
|
3
|
-
|
4
|
-
describe Yt::ContentDetail do
|
5
|
-
subject(:content_detail) { Yt::ContentDetail.new data: data }
|
6
|
-
|
7
|
-
describe '#data' do
|
8
|
-
let(:data) { {"key"=>"value"} }
|
9
|
-
specify 'returns the data the content detail was initialized with' do
|
10
|
-
expect(content_detail.data).to eq data
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#duration' do
|
15
|
-
context 'given a content_detail with duration in weeks, days, hours, minutes' do
|
16
|
-
let(:data) { {"duration"=>"P1W2DT6H21M32S"}}
|
17
|
-
it { expect(content_detail.duration).to eq 800492 }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'given a content_detail with duration in days' do
|
21
|
-
let(:data) { {"duration"=>"P1D"}}
|
22
|
-
it { expect(content_detail.duration).to eq 86400 }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'given a content_detail with duration in hours, minutes, seconds' do
|
26
|
-
let(:data) { {"duration"=>"PT1H18M52S"} }
|
27
|
-
it { expect(content_detail.duration).to eq 4732 }
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'given a content_detail with duration in minutes and seconds' do
|
31
|
-
let(:data) { {"duration"=>"PT2M51S"} }
|
32
|
-
it { expect(content_detail.duration).to eq 171 }
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'given a content_detail with duration in minutes' do
|
36
|
-
let(:data) { {"duration"=>"PT2M"} }
|
37
|
-
it { expect(content_detail.duration).to eq 120 }
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'given a content_detail with duration in seconds' do
|
41
|
-
let(:data) { {"duration"=>"PT51S"} }
|
42
|
-
it { expect(content_detail.duration).to eq 51 }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#length' do
|
47
|
-
context 'returns the duration in HH:MM:SS' do
|
48
|
-
let(:data) { {"duration"=>"PT1H18M52S"} }
|
49
|
-
it { expect(content_detail.length).to eq '01:18:52' }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/file_detail'
|
3
|
-
|
4
|
-
describe Yt::FileDetail do
|
5
|
-
subject(:file_detail) { Yt::FileDetail.new data: data }
|
6
|
-
|
7
|
-
describe '#data' do
|
8
|
-
let(:data) { {"key"=>"value"} }
|
9
|
-
specify 'returns the data the file detail was initialized with' do
|
10
|
-
expect(file_detail.data).to eq data
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/ownership'
|
3
|
-
|
4
|
-
describe Yt::Ownership do
|
5
|
-
subject(:ownership) { Yt::Ownership.new data: data }
|
6
|
-
let(:data) { {} }
|
7
|
-
|
8
|
-
describe '#general_owners' do
|
9
|
-
context 'given fetching an ownership returns a general owner' do
|
10
|
-
let(:general) { '{"ratio":100.0,"owner":"FullScreen","type":"exclude"}' }
|
11
|
-
let(:data) { {"general"=>[general]} }
|
12
|
-
it { expect(ownership.general_owners.size).to be 1 }
|
13
|
-
it { expect(ownership.general_owners.first).to be_a Yt::RightOwner }
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'given fetching an ownership does not return general owners' do
|
17
|
-
it { expect(ownership.general_owners).to be_empty }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#performance_owners' do
|
22
|
-
context 'given fetching an ownership returns a performance owner' do
|
23
|
-
let(:performance) { '{"ratio":100.0,"owner":"FullScreen","type":"exclude"}' }
|
24
|
-
let(:data) { {"performance"=>[performance]} }
|
25
|
-
it { expect(ownership.performance_owners.size).to be 1 }
|
26
|
-
it { expect(ownership.performance_owners.first).to be_a Yt::RightOwner }
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'given fetching an ownership does not return performance owners' do
|
30
|
-
it { expect(ownership.performance_owners).to be_empty }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#synchronization_owners' do
|
35
|
-
context 'given fetching an ownership returns a synchronization owner' do
|
36
|
-
let(:synchronization) { '{"ratio":100.0,"owner":"FullScreen","type":"exclude"}' }
|
37
|
-
let(:data) { {"synchronization"=>[synchronization]} }
|
38
|
-
it { expect(ownership.synchronization_owners.size).to be 1 }
|
39
|
-
it { expect(ownership.synchronization_owners.first).to be_a Yt::RightOwner }
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'given fetching an ownership does not return synchronization owners' do
|
43
|
-
it { expect(ownership.synchronization_owners).to be_empty }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#mechanical_owners' do
|
48
|
-
context 'given fetching an ownership returns a mechanical owner' do
|
49
|
-
let(:mechanical) { '{"ratio":100.0,"owner":"FullScreen","type":"exclude"}' }
|
50
|
-
let(:data) { {"mechanical"=>[mechanical]} }
|
51
|
-
it { expect(ownership.mechanical_owners.size).to be 1 }
|
52
|
-
it { expect(ownership.mechanical_owners.first).to be_a Yt::RightOwner }
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'given fetching an ownership does not return mechanical owners' do
|
56
|
-
it { expect(ownership.mechanical_owners).to be_empty }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/spec/models/player_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/player'
|
3
|
-
|
4
|
-
describe Yt::Player do
|
5
|
-
subject(:player) { Yt::Player.new data: data }
|
6
|
-
|
7
|
-
describe '#data' do
|
8
|
-
let(:data) { {"key"=>"value"} }
|
9
|
-
specify 'returns the data the player was initialized with' do
|
10
|
-
expect(player.data).to eq data
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/playlist_item'
|
3
|
-
|
4
|
-
describe Yt::PlaylistItem do
|
5
|
-
subject(:item) { Yt::PlaylistItem.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(item.title).to eq 'Fullscreen' }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'given a snippet without a title' do
|
14
|
-
let(:attrs) { {snippet: {}} }
|
15
|
-
it { expect(item.title).to eq '' }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#published_at' do
|
20
|
-
context 'given a snippet with a timestamp' do
|
21
|
-
let(:attrs) { {snippet: {"publishedAt"=>"2014-04-22T19:14:49.000Z"}} }
|
22
|
-
it { expect(item.published_at.year).to be 2014 }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#description' do
|
27
|
-
context 'given a snippet with a description' do
|
28
|
-
let(:attrs) { {snippet: {"description"=>"A video."}} }
|
29
|
-
it { expect(item.description).to eq 'A video.' }
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'given a snippet without a description' do
|
33
|
-
let(:attrs) { {snippet: {}} }
|
34
|
-
it { expect(item.description).to eq '' }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#thumbnail_url' do
|
39
|
-
context 'given a snippet with thumbnails' do
|
40
|
-
let(:attrs) { {snippet: {"thumbnails"=>{
|
41
|
-
"default"=>{"url"=> "http://example.com/120x90.jpg"},
|
42
|
-
"medium"=>{"url"=> "http://example.com/320x180.jpg"},
|
43
|
-
}}} }
|
44
|
-
it { expect(item.thumbnail_url).to eq 'http://example.com/120x90.jpg' }
|
45
|
-
it { expect(item.thumbnail_url 'default').to eq 'http://example.com/120x90.jpg' }
|
46
|
-
it { expect(item.thumbnail_url :default).to eq 'http://example.com/120x90.jpg' }
|
47
|
-
it { expect(item.thumbnail_url :medium).to eq 'http://example.com/320x180.jpg' }
|
48
|
-
it { expect(item.thumbnail_url :large).to be_nil }
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'given a snippet without thumbnails' do
|
52
|
-
let(:attrs) { {snippet: {}} }
|
53
|
-
it { expect(item.thumbnail_url).to be_nil }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#channel_id' do
|
58
|
-
context 'given a snippet with a channel ID' do
|
59
|
-
let(:attrs) { {snippet: {"channelId"=>"UCxO1tY8h1AhOz0T4ENwmpow"}} }
|
60
|
-
it { expect(item.channel_id).to eq 'UCxO1tY8h1AhOz0T4ENwmpow' }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'given a snippet without a channel ID' do
|
64
|
-
let(:attrs) { {snippet: {}} }
|
65
|
-
it { expect(item.channel_id).to be_nil }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#channel_title' do
|
70
|
-
context 'given a snippet with a channel title' do
|
71
|
-
let(:attrs) { {snippet: {"channelTitle"=>"Fullscreen"}} }
|
72
|
-
it { expect(item.channel_title).to eq 'Fullscreen' }
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'given a snippet without a channel title' do
|
76
|
-
let(:attrs) { {snippet: {}} }
|
77
|
-
it { expect(item.channel_title).to be_nil }
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#video_id and #video' do
|
82
|
-
context 'given a snippet with a video resource' do
|
83
|
-
let(:attrs) { {snippet: {"resourceId"=>{"kind"=>"youtube#video","videoId"=>"W4GhTprSsOY"}}} }
|
84
|
-
it { expect(item.video_id).to eq 'W4GhTprSsOY' }
|
85
|
-
it { expect(item.video).to be_a Yt::Models::Video }
|
86
|
-
it { expect(item.video.id).to eq 'W4GhTprSsOY' }
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'given a snippet without a video resource' do
|
90
|
-
let(:attrs) { {snippet: {}} }
|
91
|
-
it { expect(item.video_id).to be_nil }
|
92
|
-
it { expect(item.video).to be_nil }
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#snippet' do
|
97
|
-
context 'given fetching a playlist item returns a snippet' do
|
98
|
-
let(:attrs) { {snippet: {"position"=>0}} }
|
99
|
-
it { expect(item.snippet).to be_a Yt::Snippet }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe '#status' do
|
104
|
-
context 'given fetching a playlist item returns a status' do
|
105
|
-
let(:attrs) { {status: {"privacyStatus"=>"public"}} }
|
106
|
-
it { expect(item.status).to be_a Yt::Status }
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe '#delete' do
|
111
|
-
let(:attrs) { {id: 'playlist-item-id'} }
|
112
|
-
|
113
|
-
context 'given an existing playlist item' do
|
114
|
-
before { expect(item).to receive(:do_delete).and_yield }
|
115
|
-
|
116
|
-
it { expect(item.delete).to be true }
|
117
|
-
it { expect{item.delete}.to change{item.exists?} }
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|