video_info 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/lib/video_info/providers/vimeo.rb +1 -1
- data/lib/video_info/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_This_video_does_not_exist_or_has_been_deleted_/{available_ → _available_}/.yml +12 -19
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_valid_video/{available_ → _available_}/.yml +10 -15
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/{view_count → _date}/.yml +12 -17
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/{keywords → _description}/.yml +12 -17
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/{date → _duration}/.yml +12 -17
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/{thumbnail_large → _keywords}/.yml +12 -17
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_large/.yml +58 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_medium/.yml +58 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_small/.yml +58 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_title/.yml +58 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_view_count/.yml +58 -0
- data/spec/fixtures/vcr_cassettes/{VideoInfo_Providers_VimeoPlaylist/_available_/with_valid_playlist/available_ → VideoInfo_Providers_Vimeo/_available_/with_password_required_video/_available_}/.yml +28 -36
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_this_video_does_not_exist_video/{available_ → _available_}/.yml +11 -11
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_valid_video/{available_ → _available_}/.yml +13 -13
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_date/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_description/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_duration/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_height/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_keywords/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_large/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_medium/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_small/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_title/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_view_count/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_width/.yml +73 -0
- data/spec/fixtures/vcr_cassettes/{VideoInfo_Providers_Vimeo/_available_/with_password_required_video/available_ → VideoInfo_Providers_VimeoPlaylist/_available_/with_invalid_playlist/_available_}/.yml +12 -12
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/_available_/with_valid_playlist/_available_/.yml +54 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_1921098/_description/.yml +71 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_1921098/_thumbnail_large/.yml +71 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_1921098/_thumbnail_medium/.yml +71 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_1921098/_thumbnail_small/.yml +71 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_1921098/_title/.yml +71 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_1921098/_videos/.yml +104 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_invalid_video/_available_/.yml +46 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_valid_video/_available_/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video-54799401_165822734/_title/.yml +1363 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_description/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_duration/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_embed_code/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_embed_url/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_height/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_keywords/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_title/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_view_count/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/_width/.yml +1137 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_valid_video/{available_ → _available_}/.yml +9 -9
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_video_is_unavailable_video/{available_ → _available_}/.yml +6 -6
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_video_no_longer_available_due_to_a_copyright_claim_video/{available_ → _available_}/.yml +6 -6
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_date/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_description/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_duration/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_keywords/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_thumbnail_large/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_thumbnail_medium/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_thumbnail_small/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_title/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_view_count/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_invalid_playlist/{available_ → _available_}/.yml +6 -6
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_valid_playlist/{available_ → _available_}/.yml +9 -9
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL0E8117603D70E10A_in_embed_path/_videos/.yml +61 -0
- data/spec/fixtures/vcr_cassettes/{VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/title → VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_description}/.yml +27 -95
- data/spec/fixtures/vcr_cassettes/{VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/thumbnail_medium → VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_large}/.yml +31 -97
- data/spec/fixtures/vcr_cassettes/{VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/thumbnail_small → VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_medium}/.yml +31 -101
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_small/.yml +98 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_title/.yml +98 -0
- data/spec/fixtures/vcr_cassettes/{VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/description → VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_videos}/.yml +27 -95
- data/spec/lib/video_info/providers/dailymotion_spec.rb +101 -23
- data/spec/lib/video_info/providers/vimeo_playlist_spec.rb +110 -32
- data/spec/lib/video_info/providers/vimeo_spec.rb +134 -29
- data/spec/lib/video_info/providers/vkontakte_spec.rb +95 -21
- data/spec/lib/video_info/providers/youtube_playlist_spec.rb +110 -25
- data/spec/lib/video_info/providers/youtube_spec.rb +206 -47
- data/spec/lib/video_info_spec.rb +20 -20
- data/spec/spec_helper.rb +1 -5
- data/video_info.gemspec +1 -0
- metadata +148 -178
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_video_is_unavailable_video/available_/.yml +0 -46
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_video_no_longer_available_due_to_a_copyright_claim_video/available_/.yml +0 -46
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/description/.yml +0 -63
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/duration/.yml +0 -63
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/thumbnail_medium/.yml +0 -63
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/thumbnail_small/.yml +0 -63
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/title/.yml +0 -63
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/date/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/description/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/duration/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/height/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/keywords/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/thumbnail_large/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/thumbnail_medium/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/thumbnail_small/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/title/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/view_count/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/width/.yml +0 -76
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/_available_/with_invalid_playlist/available_/.yml +0 -152
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/date/.yml +0 -75
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/duration/.yml +0 -75
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/height/.yml +0 -71
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/keywords/.yml +0 -75
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/thumbnail_large/.yml +0 -168
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/videos/.yml +0 -202
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/view_count/.yml +0 -71
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_VimeoPlaylist/with_playlist_2755718/width/.yml +0 -71
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_invalid_video/available_/.yml +0 -147
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_valid_video/available_/.yml +0 -1115
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/description/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/duration/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/embed_code/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/embed_url/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/height/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/keywords/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/title/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/view_count/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/width/.yml +0 -1139
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video-54799401_165822734/title/.yml +0 -1331
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/description/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/duration/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/embed_code/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/embed_url/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/height/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/keywords/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/title/.yml +0 -1084
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/view_count/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/width/.yml +0 -1125
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/date/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/description/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/duration/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/keywords/.yml +0 -63
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/thumbnail_large/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/thumbnail_medium/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/thumbnail_small/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/title/.yml +0 -63
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/view_count/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL0E8117603D70E10A_in_embed_path/videos/.yml +0 -61
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/.yml +0 -98
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/date/.yml +0 -98
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/description/.yml +0 -98
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/duration/.yml +0 -98
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/keywords/.yml +0 -98
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/thumbnail_large/.yml +0 -96
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/thumbnail_medium/.yml +0 -96
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/thumbnail_small/.yml +0 -98
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/title/.yml +0 -98
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/videos/.yml +0 -96
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/view_count/.yml +0 -98
@@ -7,61 +7,136 @@ describe VideoInfo::Providers::Youtube do
|
|
7
7
|
|
8
8
|
context "with youtube.com url" do
|
9
9
|
let(:url) { 'http://www.youtube.com/watch?v=Xp6CXF' }
|
10
|
-
it {
|
10
|
+
it { is_expected.to be_truthy }
|
11
11
|
end
|
12
12
|
|
13
13
|
context "with youtu.be url" do
|
14
14
|
let(:url) { 'http://youtu.be/JM9NgvjjVng' }
|
15
|
-
it {
|
15
|
+
it { is_expected.to be_truthy }
|
16
16
|
end
|
17
17
|
|
18
18
|
context "with other url" do
|
19
19
|
let(:url) { 'http://google.com/video1' }
|
20
|
-
it {
|
20
|
+
it { is_expected.to be_falsey }
|
21
21
|
end
|
22
22
|
|
23
23
|
context "with playlist url" do
|
24
24
|
let(:url) { 'http://www.youtube.com/playlist?p=PLA575C81A1FBC04CF' }
|
25
|
-
it {
|
25
|
+
it { is_expected.to be_falsey }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "#available?" do
|
30
30
|
context "with valid video", :vcr do
|
31
31
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
32
|
-
|
32
|
+
|
33
|
+
describe '#available?' do
|
34
|
+
subject { super().available? }
|
35
|
+
it { is_expected.to be_truthy }
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
context "with 'video is unavailable' video", :vcr do
|
36
40
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=SUkXvWn1m7Q') }
|
37
|
-
|
41
|
+
|
42
|
+
describe '#available?' do
|
43
|
+
subject { super().available? }
|
44
|
+
it { is_expected.to be_falsey }
|
45
|
+
end
|
38
46
|
end
|
39
47
|
|
40
48
|
context "with 'video no longer available due to a copyright claim' video", :vcr do
|
41
49
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=ffClNhwx0KU') }
|
42
|
-
|
50
|
+
|
51
|
+
describe '#available?' do
|
52
|
+
subject { super().available? }
|
53
|
+
it { is_expected.to be_falsey }
|
54
|
+
end
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
46
58
|
context "with video mZqGqE0D0n4", :vcr do
|
47
59
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
48
60
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
describe '#provider' do
|
62
|
+
subject { super().provider }
|
63
|
+
it { is_expected.to eq 'YouTube' }
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#video_id' do
|
67
|
+
subject { super().video_id }
|
68
|
+
it { is_expected.to eq 'mZqGqE0D0n4' }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#url' do
|
72
|
+
subject { super().url }
|
73
|
+
it { is_expected.to eq 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#embed_url' do
|
77
|
+
subject { super().embed_url }
|
78
|
+
it { is_expected.to eq '//www.youtube.com/embed/mZqGqE0D0n4' }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#embed_code' do
|
82
|
+
subject { super().embed_code }
|
83
|
+
it { is_expected.to eq '<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" frameborder="0" allowfullscreen="allowfullscreen"></iframe>' }
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#title' do
|
87
|
+
subject { super().title }
|
88
|
+
it { is_expected.to eq 'Cherry Bloom - King Of The Knife' }
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#description' do
|
92
|
+
subject { super().description }
|
93
|
+
it { is_expected.to eq 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#keywords' do
|
97
|
+
subject { super().keywords }
|
98
|
+
it { is_expected.to be_nil }
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#duration' do
|
102
|
+
subject { super().duration }
|
103
|
+
it { is_expected.to eq 176 }
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '#width' do
|
107
|
+
subject { super().width }
|
108
|
+
it { is_expected.to be_nil }
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#height' do
|
112
|
+
subject { super().height }
|
113
|
+
it { is_expected.to be_nil }
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#date' do
|
117
|
+
subject { super().date }
|
118
|
+
it { is_expected.to eq Time.parse('Sat Apr 12 22:25:35 UTC 2008', Time.now.utc) }
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#thumbnail_small' do
|
122
|
+
subject { super().thumbnail_small }
|
123
|
+
it { is_expected.to eq 'http://i.ytimg.com/vi/mZqGqE0D0n4/default.jpg' }
|
124
|
+
end
|
125
|
+
|
126
|
+
describe '#thumbnail_medium' do
|
127
|
+
subject { super().thumbnail_medium }
|
128
|
+
it { is_expected.to eq 'http://i.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg' }
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#thumbnail_large' do
|
132
|
+
subject { super().thumbnail_large }
|
133
|
+
it { is_expected.to eq 'http://i.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg' }
|
134
|
+
end
|
135
|
+
|
136
|
+
describe '#view_count' do
|
137
|
+
subject { super().view_count }
|
138
|
+
it { is_expected.to be > 4000 }
|
139
|
+
end
|
65
140
|
end
|
66
141
|
|
67
142
|
context "with video oQ49W_xKzKA", :vcr do
|
@@ -73,79 +148,160 @@ describe VideoInfo::Providers::Youtube do
|
|
73
148
|
context "with video oQ49W_xKzKA", :vcr do
|
74
149
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=oQ49W_xKzKA') }
|
75
150
|
|
76
|
-
|
77
|
-
|
151
|
+
describe '#provider' do
|
152
|
+
subject { super().provider }
|
153
|
+
it { is_expected.to eq 'YouTube' }
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#video_id' do
|
157
|
+
subject { super().video_id }
|
158
|
+
it { is_expected.to eq 'oQ49W_xKzKA' }
|
159
|
+
end
|
78
160
|
end
|
79
161
|
|
80
162
|
context "with video Xp6CXF-Cesg", :vcr do
|
81
163
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=Xp6CXF-Cesg') }
|
82
164
|
|
83
|
-
|
84
|
-
|
165
|
+
describe '#provider' do
|
166
|
+
subject { super().provider }
|
167
|
+
it { is_expected.to eq 'YouTube' }
|
168
|
+
end
|
169
|
+
|
170
|
+
describe '#video_id' do
|
171
|
+
subject { super().video_id }
|
172
|
+
it { is_expected.to eq 'Xp6CXF-Cesg' }
|
173
|
+
end
|
85
174
|
end
|
86
175
|
|
87
176
|
context "with video VeasFckfMHY in user url", :vcr do
|
88
177
|
subject { VideoInfo.new('http://www.youtube.com/user/EducatorVids3?v=VeasFckfMHY') }
|
89
178
|
|
90
|
-
|
91
|
-
|
92
|
-
|
179
|
+
describe '#provider' do
|
180
|
+
subject { super().provider }
|
181
|
+
it { is_expected.to eq 'YouTube' }
|
182
|
+
end
|
183
|
+
|
184
|
+
describe '#video_id' do
|
185
|
+
subject { super().video_id }
|
186
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
187
|
+
end
|
188
|
+
|
189
|
+
describe '#url' do
|
190
|
+
subject { super().url }
|
191
|
+
it { is_expected.to eq 'http://www.youtube.com/user/EducatorVids3?v=VeasFckfMHY' }
|
192
|
+
end
|
93
193
|
end
|
94
194
|
|
95
195
|
context "with video VeasFckfMHY after params", :vcr do
|
96
196
|
subject { VideoInfo.new('http://www.youtube.com/watch?feature=player_profilepage&v=VeasFckfMHY') }
|
97
197
|
|
98
|
-
|
99
|
-
|
100
|
-
|
198
|
+
describe '#provider' do
|
199
|
+
subject { super().provider }
|
200
|
+
it { is_expected.to eq 'YouTube' }
|
201
|
+
end
|
202
|
+
|
203
|
+
describe '#video_id' do
|
204
|
+
subject { super().video_id }
|
205
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
206
|
+
end
|
207
|
+
|
208
|
+
describe '#url' do
|
209
|
+
subject { super().url }
|
210
|
+
it { is_expected.to eq 'http://www.youtube.com/watch?feature=player_profilepage&v=VeasFckfMHY' }
|
211
|
+
end
|
101
212
|
end
|
102
213
|
|
103
214
|
context "with video VeasFckfMHY in path", :vcr do
|
104
215
|
subject { VideoInfo.new('http://www.youtube.com/v/VeasFckfMHY') }
|
105
216
|
|
106
|
-
|
107
|
-
|
217
|
+
describe '#provider' do
|
218
|
+
subject { super().provider }
|
219
|
+
it { is_expected.to eq 'YouTube' }
|
220
|
+
end
|
221
|
+
|
222
|
+
describe '#video_id' do
|
223
|
+
subject { super().video_id }
|
224
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
225
|
+
end
|
108
226
|
end
|
109
227
|
|
110
228
|
context "with video VeasFckfMHY in e path", :vcr do
|
111
229
|
subject { VideoInfo.new('http://www.youtube.com/e/VeasFckfMHY') }
|
112
230
|
|
113
|
-
|
114
|
-
|
231
|
+
describe '#provider' do
|
232
|
+
subject { super().provider }
|
233
|
+
it { is_expected.to eq 'YouTube' }
|
234
|
+
end
|
235
|
+
|
236
|
+
describe '#video_id' do
|
237
|
+
subject { super().video_id }
|
238
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
239
|
+
end
|
115
240
|
end
|
116
241
|
|
117
242
|
context "with video VeasFckfMHY in embed path", :vcr do
|
118
243
|
subject { VideoInfo.new('http://www.youtube.com/embed/VeasFckfMHY') }
|
119
244
|
|
120
|
-
|
121
|
-
|
245
|
+
describe '#provider' do
|
246
|
+
subject { super().provider }
|
247
|
+
it { is_expected.to eq 'YouTube' }
|
248
|
+
end
|
249
|
+
|
250
|
+
describe '#video_id' do
|
251
|
+
subject { super().video_id }
|
252
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
253
|
+
end
|
122
254
|
end
|
123
255
|
|
124
256
|
context "with video JM9NgvjjVng in youtu.be url", :vcr do
|
125
257
|
subject { VideoInfo.new('http://youtu.be/JM9NgvjjVng') }
|
126
258
|
|
127
|
-
|
128
|
-
|
259
|
+
describe '#provider' do
|
260
|
+
subject { super().provider }
|
261
|
+
it { is_expected.to eq 'YouTube' }
|
262
|
+
end
|
263
|
+
|
264
|
+
describe '#video_id' do
|
265
|
+
subject { super().video_id }
|
266
|
+
it { is_expected.to eq 'JM9NgvjjVng' }
|
267
|
+
end
|
129
268
|
end
|
130
269
|
|
131
270
|
context 'without http or www', :vcr do
|
132
271
|
subject { VideoInfo.new('youtu.be/JM9NgvjjVng') }
|
133
272
|
|
134
|
-
|
135
|
-
|
273
|
+
describe '#provider' do
|
274
|
+
subject { super().provider }
|
275
|
+
it { is_expected.to eq('YouTube') }
|
276
|
+
end
|
277
|
+
|
278
|
+
describe '#video_id' do
|
279
|
+
subject { super().video_id }
|
280
|
+
it { is_expected.to eq 'JM9NgvjjVng' }
|
281
|
+
end
|
136
282
|
end
|
137
283
|
|
138
284
|
context "with video url in text", :vcr do
|
139
285
|
subject { VideoInfo.new('<a href="http://www.youtube.com/watch?v=mZqGqE0D0n4">http://www.youtube.com/watch?v=mZqGqE0D0n4</a>') }
|
140
286
|
|
141
|
-
|
142
|
-
|
287
|
+
describe '#provider' do
|
288
|
+
subject { super().provider }
|
289
|
+
it { is_expected.to eq('YouTube') }
|
290
|
+
end
|
291
|
+
|
292
|
+
describe '#video_id' do
|
293
|
+
subject { super().video_id }
|
294
|
+
it { is_expected.to eq('mZqGqE0D0n4') }
|
295
|
+
end
|
143
296
|
end
|
144
297
|
|
145
298
|
context "with iframe attributes", :vcr do
|
146
299
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
147
300
|
|
148
|
-
|
301
|
+
describe '#provider' do
|
302
|
+
subject { super().provider }
|
303
|
+
it { is_expected.to eq('YouTube') }
|
304
|
+
end
|
149
305
|
it { expect(subject.embed_code(iframe_attributes: { width: 800, height: 600 })).to match(/width="800"/) }
|
150
306
|
it { expect(subject.embed_code(iframe_attributes: { width: 800, height: 600 })).to match(/height="600"/) }
|
151
307
|
end
|
@@ -153,7 +309,10 @@ describe VideoInfo::Providers::Youtube do
|
|
153
309
|
context "with arbitrary iframe_attributes", :vcr do
|
154
310
|
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
155
311
|
|
156
|
-
|
312
|
+
describe '#provider' do
|
313
|
+
subject { super().provider }
|
314
|
+
it { is_expected.to eq('YouTube') }
|
315
|
+
end
|
157
316
|
it { expect(subject.embed_code(iframe_attributes: { :'data-colorbox' => true })).to match(/data-colorbox="true"/) }
|
158
317
|
end
|
159
318
|
|
data/spec/lib/video_info_spec.rb
CHANGED
@@ -8,18 +8,18 @@ describe VideoInfo do
|
|
8
8
|
let(:provider) { double('provider', provider: 'Provider') }
|
9
9
|
|
10
10
|
it "uses the first usable provider" do
|
11
|
-
VideoInfo::Providers::Vimeo.
|
12
|
-
VideoInfo::Providers::Vkontakte.
|
13
|
-
VideoInfo::Providers::Youtube.
|
14
|
-
VideoInfo::Providers::Youtube.
|
11
|
+
allow(VideoInfo::Providers::Vimeo).to receive(:usable?) { false }
|
12
|
+
allow(VideoInfo::Providers::Vkontakte).to receive(:usable?) { false }
|
13
|
+
allow(VideoInfo::Providers::Youtube).to receive(:usable?) { true }
|
14
|
+
allow(VideoInfo::Providers::Youtube).to receive(:new) { provider }
|
15
15
|
|
16
16
|
expect(VideoInfo.new(url, options).provider).to eq 'Provider'
|
17
17
|
end
|
18
18
|
|
19
19
|
it "raise when no providers are usable" do
|
20
|
-
VideoInfo::Providers::Vimeo.
|
21
|
-
VideoInfo::Providers::Vkontakte.
|
22
|
-
VideoInfo::Providers::Youtube.
|
20
|
+
allow(VideoInfo::Providers::Vimeo).to receive(:usable?) { false }
|
21
|
+
allow(VideoInfo::Providers::Vkontakte).to receive(:usable?) { false }
|
22
|
+
allow(VideoInfo::Providers::Youtube).to receive(:usable?) { false }
|
23
23
|
|
24
24
|
expect { VideoInfo.new(url, options) }.to raise_error(VideoInfo::UrlError)
|
25
25
|
end
|
@@ -30,20 +30,20 @@ describe VideoInfo do
|
|
30
30
|
let(:provider) { double('provider', new: true) }
|
31
31
|
|
32
32
|
it "returns true when a provider is usable" do
|
33
|
-
VideoInfo::Providers::Vimeo.
|
34
|
-
VideoInfo::Providers::Vkontakte.
|
35
|
-
VideoInfo::Providers::Youtube.
|
36
|
-
VideoInfo::Providers::Youtube.
|
33
|
+
allow(VideoInfo::Providers::Vimeo).to receive(:usable?) { false }
|
34
|
+
allow(VideoInfo::Providers::Vkontakte).to receive(:usable?) { false }
|
35
|
+
allow(VideoInfo::Providers::Youtube).to receive(:usable?) { true }
|
36
|
+
allow(VideoInfo::Providers::Youtube).to receive(:new) { true }
|
37
37
|
|
38
|
-
expect(VideoInfo.usable?(url)).to
|
38
|
+
expect(VideoInfo.usable?(url)).to be_truthy
|
39
39
|
end
|
40
40
|
|
41
41
|
it "returns false when no providers are usable" do
|
42
|
-
VideoInfo::Providers::Vimeo.
|
43
|
-
VideoInfo::Providers::Vkontakte.
|
44
|
-
VideoInfo::Providers::Youtube.
|
42
|
+
allow(VideoInfo::Providers::Vimeo).to receive(:usable?) { false }
|
43
|
+
allow(VideoInfo::Providers::Vkontakte).to receive(:usable?) { false }
|
44
|
+
allow(VideoInfo::Providers::Youtube).to receive(:usable?) { false }
|
45
45
|
|
46
|
-
expect(VideoInfo.usable?(url)).to
|
46
|
+
expect(VideoInfo.usable?(url)).to be_falsey
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -54,15 +54,15 @@ describe VideoInfo do
|
|
54
54
|
|
55
55
|
context "matching" do
|
56
56
|
it "returns true" do
|
57
|
-
expect(vi_a == vi_a).to
|
58
|
-
expect(vi_a == vi_b).to
|
57
|
+
expect(vi_a == vi_a).to be_truthy
|
58
|
+
expect(vi_a == vi_b).to be_truthy
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
context "not matching" do
|
63
63
|
it "returns false" do
|
64
|
-
expect(vi_a == vi_c).to
|
65
|
-
expect(vi_b == vi_c).to
|
64
|
+
expect(vi_a == vi_c).to be_falsey
|
65
|
+
expect(vi_b == vi_c).to be_falsey
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'rspec/its'
|
2
3
|
require 'video_info'
|
3
4
|
require 'vcr'
|
4
5
|
|
@@ -18,11 +19,6 @@ VCR.configure do |config|
|
|
18
19
|
end
|
19
20
|
|
20
21
|
RSpec.configure do |config|
|
21
|
-
config.color_enabled = true
|
22
22
|
config.filter_run focus: true
|
23
23
|
config.run_all_when_everything_filtered = true
|
24
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
25
|
-
config.expect_with :rspec do |c|
|
26
|
-
c.syntax = :expect
|
27
|
-
end
|
28
24
|
end
|
data/video_info.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_development_dependency 'bundler', '>= 1.3.5'
|
28
28
|
s.add_development_dependency 'rake'
|
29
29
|
s.add_development_dependency 'rspec'
|
30
|
+
s.add_development_dependency 'rspec-its'
|
30
31
|
s.add_development_dependency 'vcr'
|
31
32
|
s.add_development_dependency 'webmock'
|
32
33
|
end
|