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
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/collections/comment_threads'
|
3
|
-
require 'yt/models/video'
|
4
|
-
require 'yt/models/channel'
|
5
|
-
|
6
|
-
describe Yt::Collections::CommentThreads do
|
7
|
-
subject(:collection) { Yt::Collections::CommentThreads.new parent: parent}
|
8
|
-
|
9
|
-
describe '#size', :ruby2 do
|
10
|
-
describe 'sends only one request and return the total results' do
|
11
|
-
let(:total_results) { 1234 }
|
12
|
-
let(:parent) { Yt::Video.new id: 'any-id' }
|
13
|
-
|
14
|
-
before do
|
15
|
-
expect_any_instance_of(Yt::Request).to receive(:run).once do
|
16
|
-
double(body: {'pageInfo'=>{'totalResults'=>total_results}})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
it { expect(collection.size).to be total_results }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#count' do
|
24
|
-
let(:query) { {q: 'search string'} }
|
25
|
-
let(:parent) { Yt::Video.new id: 'any-id' }
|
26
|
-
let(:page) { {items: [], token: 'any-token'} }
|
27
|
-
|
28
|
-
context 'called once with .where(query) and once without' do
|
29
|
-
after do
|
30
|
-
collection.where(query).count
|
31
|
-
collection.count
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'only applies the query on the first call' do
|
35
|
-
expect(collection).to receive(:fetch_page) do |options|
|
36
|
-
expect(options[:params]).to include query
|
37
|
-
page
|
38
|
-
end
|
39
|
-
expect(collection).to receive(:fetch_page) do |options|
|
40
|
-
expect(options[:params]).not_to include query
|
41
|
-
page
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/models/playlist'
|
3
|
-
require 'yt/models/playlist_item'
|
4
|
-
require 'yt/collections/playlist_items'
|
5
|
-
|
6
|
-
describe Yt::Collections::PlaylistItems do
|
7
|
-
subject(:collection) { Yt::Collections::PlaylistItems.new parent: playlist }
|
8
|
-
let(:playlist) { Yt::Playlist.new id: 'LLxO1tY8h1AhOz0T4ENwmpow' }
|
9
|
-
let(:attrs) { {id: '9bZkp7q19f0', kind: :video} }
|
10
|
-
let(:msg) { {response_body: {error: {errors: [{reason: reason}]}}}.to_json }
|
11
|
-
before { expect(collection).to behave }
|
12
|
-
|
13
|
-
describe '#insert' do
|
14
|
-
let(:playlist_item) { Yt::PlaylistItem.new }
|
15
|
-
|
16
|
-
context 'given an existing video' do
|
17
|
-
let(:behave) { receive(:do_insert).and_return playlist_item }
|
18
|
-
|
19
|
-
it { expect(collection.insert attrs).to eq playlist_item }
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'given an unknown video' do
|
23
|
-
let(:reason) { 'videoNotFound' }
|
24
|
-
let(:behave) { receive(:do_insert).and_raise Yt::Error, msg }
|
25
|
-
|
26
|
-
it { expect{collection.insert attrs}.to fail.with 'videoNotFound' }
|
27
|
-
it { expect{collection.insert attrs, ignore_errors: true}.not_to fail }
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'given a forbidden video' do
|
31
|
-
let(:reason) { 'forbidden' }
|
32
|
-
let(:behave) { receive(:do_insert).and_raise Yt::Error, msg }
|
33
|
-
|
34
|
-
it { expect{collection.insert attrs}.to fail.with 'forbidden' }
|
35
|
-
it { expect{collection.insert attrs, ignore_errors: true}.not_to fail }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#delete_all' do
|
40
|
-
let(:behave) { receive(:do_delete_all).and_return [true] }
|
41
|
-
|
42
|
-
it { expect(collection.delete_all).to eq [true] }
|
43
|
-
end
|
44
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/collections/playlists'
|
3
|
-
|
4
|
-
describe Yt::Collections::Playlists do
|
5
|
-
subject(:collection) { Yt::Collections::Playlists.new }
|
6
|
-
before { expect(collection).to behave }
|
7
|
-
|
8
|
-
describe '#insert' do
|
9
|
-
let(:playlist) { Yt::Playlist.new }
|
10
|
-
# TODO: separate stubs to show options translate into do_insert params
|
11
|
-
let(:behave) { receive(:do_insert).and_return playlist }
|
12
|
-
|
13
|
-
it { expect(collection.insert).to eq playlist }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#delete_all' do
|
17
|
-
let(:behave) { receive(:do_delete_all).and_return [true] }
|
18
|
-
|
19
|
-
it { expect(collection.delete_all).to eq [true] }
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#delete_all' do
|
23
|
-
let(:behave) { receive(:do_delete_all).and_return [true] }
|
24
|
-
|
25
|
-
it { expect(collection.delete_all).to eq [true] }
|
26
|
-
end
|
27
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/collections/policies'
|
3
|
-
require 'yt/models/content_owner'
|
4
|
-
|
5
|
-
describe Yt::Collections::Policies do
|
6
|
-
subject(:collection) { Yt::Collections::Policies.new parent: content_owner }
|
7
|
-
let(:content_owner) { Yt::ContentOwner.new owner_name: 'any-name' }
|
8
|
-
let(:page) { {items: [], token: 'any-token'} }
|
9
|
-
let(:query) { {id: 'any-id'} }
|
10
|
-
|
11
|
-
describe '#count' do
|
12
|
-
context 'called once with .where(query) and once without' do
|
13
|
-
after do
|
14
|
-
collection.where(query).count
|
15
|
-
collection.count
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'only applies the query on the first call' do
|
19
|
-
expect(collection).to receive(:fetch_page) do |options|
|
20
|
-
expect(options[:params]).to include query
|
21
|
-
page
|
22
|
-
end
|
23
|
-
expect(collection).to receive(:fetch_page) do |options|
|
24
|
-
expect(options[:params]).not_to include query
|
25
|
-
page
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/collections/references'
|
3
|
-
require 'yt/models/content_owner'
|
4
|
-
|
5
|
-
describe Yt::Collections::References do
|
6
|
-
subject(:collection) { Yt::Collections::References.new parent: content_owner }
|
7
|
-
let(:content_owner) { Yt::ContentOwner.new id: 'any-id' }
|
8
|
-
let(:page) { {items: [], token: 'any-token'} }
|
9
|
-
let(:query) { {id: 'reference-id'} }
|
10
|
-
|
11
|
-
describe '#count' do
|
12
|
-
context 'called once with .where(query) and once without' do
|
13
|
-
after do
|
14
|
-
collection.where(query).count
|
15
|
-
collection.count
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'only applies the query on the first call' do
|
19
|
-
expect(collection).to receive(:fetch_page) do |options|
|
20
|
-
expect(options[:params]).to include query
|
21
|
-
page
|
22
|
-
end
|
23
|
-
expect(collection).to receive(:fetch_page) do |options|
|
24
|
-
expect(options[:params]).not_to include query
|
25
|
-
page
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/collections/reports'
|
3
|
-
require 'yt/models/content_owner'
|
4
|
-
|
5
|
-
describe Yt::Collections::Reports do
|
6
|
-
subject(:reports) { Yt::Collections::Reports.new(parent: content_owner).tap{|reports| reports.metrics = {views: Integer}} }
|
7
|
-
let(:content_owner) { Yt::ContentOwner.new owner_name: 'any-name' }
|
8
|
-
let(:error){ {reason: reason, message: message} }
|
9
|
-
let(:msg) { {response_body: {error: {errors: [error]}}}.to_json }
|
10
|
-
|
11
|
-
describe '#within' do
|
12
|
-
let(:result) { reports.within Range.new(5.days.ago, 4.days.ago), nil, nil, :day, nil, nil }
|
13
|
-
context 'given the request raises error 400 with "Invalid Query" message' do
|
14
|
-
let(:reason) { 'badRequest' }
|
15
|
-
let(:message) { 'Invalid query. Query did not conform to the expectations' }
|
16
|
-
before { expect(reports).to receive(:list).once.and_raise Yt::Error, msg }
|
17
|
-
let(:try_again) { expect(reports).to receive(:list).at_least(:once) }
|
18
|
-
|
19
|
-
context 'every time' do
|
20
|
-
before { try_again.and_raise Yt::Error, msg }
|
21
|
-
it { expect{result}.to fail }
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'but returns a success code 2XX the second time' do
|
25
|
-
before { try_again.and_return [views: {total: 20}] }
|
26
|
-
it { expect{result}.not_to fail }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/collections/subscriptions'
|
3
|
-
|
4
|
-
describe Yt::Collections::Subscriptions do
|
5
|
-
subject(:collection) { Yt::Collections::Subscriptions.new }
|
6
|
-
let(:msg) { {response_body: {error: {errors: [{reason: reason}]}}}.to_json }
|
7
|
-
before { expect(collection).to behave }
|
8
|
-
|
9
|
-
describe '#insert' do
|
10
|
-
context 'given a new subscription' do
|
11
|
-
let(:subscription) { Yt::Subscription.new }
|
12
|
-
let(:behave) { receive(:do_insert).and_return subscription }
|
13
|
-
|
14
|
-
it { expect(collection.insert).to eq subscription }
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'given a duplicate subscription' do
|
18
|
-
let(:reason) { 'subscriptionDuplicate' }
|
19
|
-
let(:behave) { receive(:do_insert).and_raise Yt::Error, msg }
|
20
|
-
|
21
|
-
it { expect{collection.insert}.to fail.with 'subscriptionDuplicate' }
|
22
|
-
it { expect{collection.insert ignore_errors: true}.not_to fail }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/collections/videos'
|
3
|
-
require 'yt/models/channel'
|
4
|
-
|
5
|
-
describe Yt::Collections::Videos do
|
6
|
-
subject(:collection) { Yt::Collections::Videos.new parent: channel }
|
7
|
-
let(:channel) { Yt::Channel.new id: 'any-id' }
|
8
|
-
let(:page) { {items: [], token: 'any-token'} }
|
9
|
-
|
10
|
-
describe '#size', :ruby2 do
|
11
|
-
describe 'sends only one request and return the total results' do
|
12
|
-
let(:total_results) { 123456 }
|
13
|
-
before do
|
14
|
-
expect_any_instance_of(Yt::Request).to receive(:run).once do
|
15
|
-
double(body: {'pageInfo'=>{'totalResults'=>total_results}})
|
16
|
-
end
|
17
|
-
end
|
18
|
-
it { expect(collection.size).to be total_results }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#count' do
|
23
|
-
let(:query) { {q: 'search string'} }
|
24
|
-
|
25
|
-
context 'called once with .where(query) and once without' do
|
26
|
-
after do
|
27
|
-
collection.where(query).count
|
28
|
-
collection.count
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'only applies the query on the first call' do
|
32
|
-
expect(collection).to receive(:fetch_page) do |options|
|
33
|
-
expect(options[:params]).to include query
|
34
|
-
page
|
35
|
-
end
|
36
|
-
expect(collection).to receive(:fetch_page) do |options|
|
37
|
-
expect(options[:params]).not_to include query
|
38
|
-
page
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/constants/geography'
|
3
|
-
|
4
|
-
describe 'Yt::COUNTRIES' do
|
5
|
-
it 'returns all country codes and names' do
|
6
|
-
expect(Yt::COUNTRIES[:US]).to eq 'United States'
|
7
|
-
expect(Yt::COUNTRIES['IT']).to eq 'Italy'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'Yt::US_STATES' do
|
12
|
-
it 'returns all U.S. state codes and names' do
|
13
|
-
expect(Yt::US_STATES[:CA]).to eq 'California'
|
14
|
-
expect(Yt::US_STATES['CO']).to eq 'Colorado'
|
15
|
-
end
|
16
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/errors/forbidden'
|
3
|
-
|
4
|
-
describe Yt::Errors::Forbidden do
|
5
|
-
let(:msg) { %r{^A request to YouTube API was considered forbidden by the server} }
|
6
|
-
|
7
|
-
describe '#exception' do
|
8
|
-
it { expect{raise Yt::Errors::Forbidden}.to raise_error msg }
|
9
|
-
end
|
10
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/errors/missing_auth'
|
3
|
-
|
4
|
-
describe Yt::Errors::MissingAuth do
|
5
|
-
subject(:error) { raise Yt::Errors::MissingAuth, params }
|
6
|
-
let(:params) { {} }
|
7
|
-
let(:msg) { %r{^A request to YouTube API was sent without a valid authentication} }
|
8
|
-
|
9
|
-
describe '#exception' do
|
10
|
-
it { expect{error}.to raise_error msg }
|
11
|
-
|
12
|
-
context 'given the user can authenticate via web' do
|
13
|
-
let(:params) { {scopes: 'youtube', authentication_url: 'http://google.example.com/auth', redirect_uri: 'http://localhost/'} }
|
14
|
-
let(:msg) { %r{^You can ask YouTube accounts to authenticate your app} }
|
15
|
-
it { expect{error}.to raise_error msg }
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'given the user can authenticate via device code' do
|
19
|
-
let(:params) { {scopes: 'youtube', user_code: 'abcdefgh', verification_url: 'http://google.com/device'} }
|
20
|
-
let(:msg) { %r{^Please authenticate your app by visiting the page} }
|
21
|
-
it { expect{error}.to raise_error msg }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'yt/errors/request_error'
|
3
|
-
|
4
|
-
describe Yt::Errors::RequestError do
|
5
|
-
subject(:error) { raise Yt::Errors::RequestError, params }
|
6
|
-
let(:params) { {} }
|
7
|
-
let(:msg) { %r{^A request to YouTube API failed} }
|
8
|
-
|
9
|
-
describe '#exception' do
|
10
|
-
it { expect{error}.to raise_error msg }
|
11
|
-
|
12
|
-
context 'given the exception includes sensitive data' do
|
13
|
-
let(:body) { 'some secret token' }
|
14
|
-
let(:curl) { 'curl -H "Authorization: secret-token"' }
|
15
|
-
let(:params) { {response_body: body, request_curl: curl}.to_json }
|
16
|
-
|
17
|
-
describe 'given a log level of :debug or :devel' do
|
18
|
-
before(:all) { Yt.configuration.log_level = :debug }
|
19
|
-
specify 'exposes sensitive data' do
|
20
|
-
expect{error}.to raise_error do |error|
|
21
|
-
expect(error.message).to include 'secret'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'given a different log level' do
|
27
|
-
before(:all) { Yt.configuration.log_level = :info }
|
28
|
-
specify 'hides sensitive data' do
|
29
|
-
expect{error}.to raise_error do |error|
|
30
|
-
expect(error.message).not_to include 'secret'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe Yt::Error do
|
39
|
-
let(:msg) { %r{^A request to YouTube API failed} }
|
40
|
-
|
41
|
-
describe '#exception' do
|
42
|
-
it { expect{raise Yt::Error}.to raise_error msg }
|
43
|
-
end
|
44
|
-
end
|
@@ -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
|