acts_as_unvlogable_fork 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +16 -0
- data/Gemfile +14 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +130 -0
- data/Rakefile +2 -0
- data/acts_as_unvlogable.gemspec +25 -0
- data/lib/acts_as_unvlogable/flickr.rb +713 -0
- data/lib/acts_as_unvlogable/object_base.rb +15 -0
- data/lib/acts_as_unvlogable/string_base.rb +24 -0
- data/lib/acts_as_unvlogable/string_extend.rb +8 -0
- data/lib/acts_as_unvlogable/version.rb +3 -0
- data/lib/acts_as_unvlogable/vg_11870.rb +48 -0
- data/lib/acts_as_unvlogable/vg_blip.rb +48 -0
- data/lib/acts_as_unvlogable/vg_collegehumor.rb +58 -0
- data/lib/acts_as_unvlogable/vg_dailymotion.rb +67 -0
- data/lib/acts_as_unvlogable/vg_dalealplay.rb +50 -0
- data/lib/acts_as_unvlogable/vg_flickr.rb +70 -0
- data/lib/acts_as_unvlogable/vg_marca.rb +48 -0
- data/lib/acts_as_unvlogable/vg_metacafe.rb +77 -0
- data/lib/acts_as_unvlogable/vg_myspace.rb +48 -0
- data/lib/acts_as_unvlogable/vg_prostopleer.rb +46 -0
- data/lib/acts_as_unvlogable/vg_qik.rb +64 -0
- data/lib/acts_as_unvlogable/vg_rutube.rb +80 -0
- data/lib/acts_as_unvlogable/vg_ted.rb +51 -0
- data/lib/acts_as_unvlogable/vg_vimeo.rb +89 -0
- data/lib/acts_as_unvlogable/vg_youtu.rb +11 -0
- data/lib/acts_as_unvlogable/vg_youtube.rb +67 -0
- data/lib/acts_as_unvlogable.rb +117 -0
- data/test/acts_as_unvlogable_test.rb +392 -0
- data/test/video_factory_test.rb +66 -0
- data/unvlogable_sample.yml +5 -0
- metadata +137 -0
@@ -0,0 +1,392 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
$LOAD_PATH << File.dirname(__FILE__) + '/../lib'
|
5
|
+
# Main class
|
6
|
+
require 'acts_as_unvlogable'
|
7
|
+
# Gems & other herbs
|
8
|
+
require 'shoulda'
|
9
|
+
require 'ruby-debug'
|
10
|
+
|
11
|
+
class ActsAsUnvlogableTest < Test::Unit::TestCase
|
12
|
+
|
13
|
+
context "Instancing UnvlogIt" do
|
14
|
+
|
15
|
+
context "without any url" do
|
16
|
+
should "raise an ArgumentError exception" do
|
17
|
+
assert_raise(ArgumentError, "We need a video url") { UnvlogIt.new }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with an unsupported url" do
|
22
|
+
should "raise an ArgumentError exception" do
|
23
|
+
assert_raise(ArgumentError, "Unsuported url or service") { UnvlogIt.new("http://iwannagothere.net/") }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# ----------------------------------------------------------
|
28
|
+
# Testing youtube
|
29
|
+
# ----------------------------------------------------------
|
30
|
+
context "with an existent youtube url" do
|
31
|
+
setup do
|
32
|
+
@videotron = UnvlogIt.new("http://www.youtube.com/watch?v=MVa4q-YVjD8") # => Keith Moon´s drum kit explodes
|
33
|
+
end
|
34
|
+
should "initialize a VgYoutube instance" do
|
35
|
+
assert_equal VgYoutube, @videotron.instance_values['object'].class
|
36
|
+
assert_equal "http://www.youtube.com/watch?v=MVa4q-YVjD8", @videotron.instance_values['object'].instance_values['url']
|
37
|
+
assert_equal "MVa4q-YVjD8", @videotron.instance_values['object'].instance_values['video_id']
|
38
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['details']
|
39
|
+
end
|
40
|
+
|
41
|
+
should "return the video properties" do
|
42
|
+
check_video_attributes({:title => "Keith Moon´s drum kit explodes", :service => "Youtube"})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "with an existent youtube url that can not be embedded" do
|
47
|
+
should "raise an ArgumentError" do
|
48
|
+
assert_raise(ArgumentError, "Embedding disabled by request") { UnvlogIt.new("http://www.youtube.com/watch?v=6TT19cB0NTM") }# => Oh! Yeah! by Chickenfoot from the Tonight Show w Conan O'Brien
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with an inexistent youtube url" do
|
53
|
+
should "raise an ArgumentError" do
|
54
|
+
assert_raise(ArgumentError, "Unsuported url or service") { UnvlogIt.new("http://www.youtube.com/watch?v=inexistente") }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# ----------------------------------------------------------
|
59
|
+
# Testing metacafe
|
60
|
+
# ----------------------------------------------------------
|
61
|
+
context "with an existent metacafe url" do
|
62
|
+
setup do
|
63
|
+
@videotron = UnvlogIt.new("http://www.metacafe.com/watch/1135061/close_call_a320_caught_in_crosswinds/") # => Close Call! A320 Caught in Crosswinds
|
64
|
+
end
|
65
|
+
should "initialize a VgMetacafe instance" do
|
66
|
+
assert_equal VgMetacafe, @videotron.instance_values['object'].class
|
67
|
+
assert_equal "http://www.metacafe.com/watch/1135061/close_call_a320_caught_in_crosswinds/", @videotron.instance_values['object'].instance_values['url']
|
68
|
+
assert_equal 3, @videotron.instance_values['object'].instance_values['args'].size
|
69
|
+
assert !@videotron.instance_values['object'].instance_values['youtubed']
|
70
|
+
assert_nil @videotron.instance_values['object'].instance_values['yt']
|
71
|
+
end
|
72
|
+
|
73
|
+
should "return the video properties" do
|
74
|
+
check_video_attributes({:title => "Close call a320 caught in crosswinds", :service => "Metacafe"})
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "with an existent 'youtubed' metacafe url" do
|
79
|
+
setup do
|
80
|
+
@videotron = UnvlogIt.new("http://www.metacafe.com/watch/yt-r07zdVLOWBA/pop_rocks_and_coke_myth/") # => Close Call! A320 Caught in Crosswinds
|
81
|
+
end
|
82
|
+
should "initialize a VgMetacafe instance" do
|
83
|
+
assert_equal VgMetacafe, @videotron.instance_values['object'].class
|
84
|
+
assert_equal "http://www.metacafe.com/watch/yt-r07zdVLOWBA/pop_rocks_and_coke_myth/", @videotron.instance_values['object'].instance_values['url']
|
85
|
+
assert_equal 3, @videotron.instance_values['object'].instance_values['args'].size
|
86
|
+
assert @videotron.instance_values['object'].instance_values['youtubed']
|
87
|
+
assert "VgYoutube", @videotron.instance_values['object'].instance_values['yt'].class.to_s
|
88
|
+
end
|
89
|
+
|
90
|
+
should "return the video properties" do
|
91
|
+
check_video_attributes({:title => "Pop Rocks and Coke Myth", :service => "Metacafe"})
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
# ----------------------------------------------------------
|
100
|
+
# Testing dailymotion
|
101
|
+
# ----------------------------------------------------------
|
102
|
+
context "with a dailymotion video url" do
|
103
|
+
setup do
|
104
|
+
@videotron = UnvlogIt.new("http://www.dailymotion.com/video/x7u5kn_parkour-dayyy_sport") # => parkour dayyy
|
105
|
+
end
|
106
|
+
should "initialize a VgDailymotion instance" do
|
107
|
+
assert_equal "VgDailymotion", @videotron.instance_values['object'].class.to_s
|
108
|
+
assert_equal "http://www.dailymotion.com/video/x7u5kn_parkour-dayyy_sport", @videotron.instance_values['object'].instance_values['url']
|
109
|
+
assert_equal "x7u5kn_parkour-dayyy_sport", @videotron.instance_values['object'].instance_values['video_id']
|
110
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['feed']
|
111
|
+
end
|
112
|
+
|
113
|
+
should "return the video properties" do
|
114
|
+
check_video_attributes({:title => "parkour dayyy", :service => "Dailymotion"})
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
# ----------------------------------------------------------
|
121
|
+
# Testing collegehumor
|
122
|
+
# ----------------------------------------------------------
|
123
|
+
context "with a collegehumor video url" do
|
124
|
+
setup do
|
125
|
+
@videotron = UnvlogIt.new("http://www.collegehumor.com/video/3005349/brohemian-rhapsody") # => Brohemian Rhapsody
|
126
|
+
end
|
127
|
+
should "initialize a VgCollegehumor instance" do
|
128
|
+
assert_equal "VgCollegehumor", @videotron.instance_values['object'].class.to_s
|
129
|
+
assert_equal "http://www.collegehumor.com/video/3005349/brohemian-rhapsody", @videotron.instance_values['object'].instance_values['url']
|
130
|
+
assert_equal "3005349", @videotron.instance_values['object'].instance_values['video_id']
|
131
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['feed']
|
132
|
+
end
|
133
|
+
|
134
|
+
should "return the video properties" do
|
135
|
+
check_video_attributes({:title => "Brohemian Rhapsody", :service => "CollegeHumor"})
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
# ----------------------------------------------------------
|
141
|
+
# Testing blip.tv
|
142
|
+
# ----------------------------------------------------------
|
143
|
+
context "with a blip.tv video url" do
|
144
|
+
setup do
|
145
|
+
@videotron = UnvlogIt.new("http://blip.tv/file/678407/") # => Toy Break 26 : Adult Toys
|
146
|
+
end
|
147
|
+
should "initialize a VgBlip instance" do
|
148
|
+
assert_equal "VgBlip", @videotron.instance_values['object'].class.to_s
|
149
|
+
assert_equal "http://blip.tv/file/678407/", @videotron.instance_values['object'].instance_values['url']
|
150
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['feed']
|
151
|
+
end
|
152
|
+
|
153
|
+
should "return the video properties" do
|
154
|
+
check_video_attributes({:title => "Toy Break 26 : Adult Toys", :service => "Blip.tv"})
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
# ----------------------------------------------------------
|
160
|
+
# Testing vids.myspace.com
|
161
|
+
# ----------------------------------------------------------
|
162
|
+
context "with a vids.myspace.com video url" do
|
163
|
+
setup do
|
164
|
+
@videotron = UnvlogIt.new("http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=27111431") # => rocabilis
|
165
|
+
end
|
166
|
+
should "initialize a VgMyspace instance" do
|
167
|
+
assert_equal "VgMyspace", @videotron.instance_values['object'].class.to_s
|
168
|
+
assert_equal "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=27111431", @videotron.instance_values['object'].instance_values['url']
|
169
|
+
assert_equal "27111431", @videotron.instance_values['object'].instance_values['video_id']
|
170
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['feed']
|
171
|
+
end
|
172
|
+
|
173
|
+
should "return the video properties" do
|
174
|
+
check_video_attributes({:title => "rocabilis", :service => "Myspace"})
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
# ----------------------------------------------------------
|
180
|
+
# Testing 11870.com
|
181
|
+
# ----------------------------------------------------------
|
182
|
+
context "with an 11870.com video url" do
|
183
|
+
setup do
|
184
|
+
@videotron = UnvlogIt.new("http://11870.com/pro/chic-basic-born/media/b606abfe") # => Chic & Basic Born
|
185
|
+
end
|
186
|
+
should "initialize a Vg11870 instance" do
|
187
|
+
assert_equal "Vg11870", @videotron.instance_values['object'].class.to_s
|
188
|
+
assert_equal "http://11870.com/pro/chic-basic-born/media/b606abfe", @videotron.instance_values['object'].instance_values['url']
|
189
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['page']
|
190
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['flashvars']
|
191
|
+
end
|
192
|
+
|
193
|
+
should "return the video properties" do
|
194
|
+
check_video_attributes({:title => "Chic & Basic Born", :service => "11870.com"})
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
# ----------------------------------------------------------
|
200
|
+
# Testing dalealplay.com
|
201
|
+
# ----------------------------------------------------------
|
202
|
+
context "with a dalealplay.com video url" do
|
203
|
+
setup do
|
204
|
+
@videotron = UnvlogIt.new("http://www.dalealplay.com/informaciondecontenido.php?con=80280") # => Camelos Semos Jonathan Tú si que vales
|
205
|
+
end
|
206
|
+
should "initialize a VgDalealplay instance" do
|
207
|
+
assert_equal "VgDalealplay", @videotron.instance_values['object'].class.to_s
|
208
|
+
assert_equal "http://www.dalealplay.com/informaciondecontenido.php?con=80280", @videotron.instance_values['object'].instance_values['url']
|
209
|
+
assert_equal "80280", @videotron.instance_values['object'].instance_values['video_id']
|
210
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['page']
|
211
|
+
end
|
212
|
+
|
213
|
+
should "return the video properties" do
|
214
|
+
check_video_attributes({:title => "Camelos.Semos. Jonathan. Tú si que vales.", :service => "dalealplay"})
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
# ----------------------------------------------------------
|
221
|
+
# Testing flickr.com
|
222
|
+
# ----------------------------------------------------------
|
223
|
+
context "with a flickr.com video url" do
|
224
|
+
setup do
|
225
|
+
@videotron = UnvlogIt.new("http://www.flickr.com/photos/jerovital/4152225414/", {:key => "065b2eff5e604e2a408c01af1f27a982" }) # => la primera vela
|
226
|
+
end
|
227
|
+
should "initialize a VgFlickr instance" do
|
228
|
+
assert_equal "VgFlickr", @videotron.instance_values['object'].class.to_s
|
229
|
+
assert_equal "http://www.flickr.com/photos/jerovital/4152225414/", @videotron.instance_values['object'].instance_values['url']
|
230
|
+
assert_equal "4152225414", @videotron.instance_values['object'].instance_values['video_id']
|
231
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['details']
|
232
|
+
end
|
233
|
+
|
234
|
+
should "return the video properties" do
|
235
|
+
check_video_attributes({:title => "flipando en los columpios", :service => "Flickr"})
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
# ----------------------------------------------------------
|
241
|
+
# Testing qik.com
|
242
|
+
# ----------------------------------------------------------
|
243
|
+
context "with a qik.com video url" do
|
244
|
+
setup do
|
245
|
+
@videotron = UnvlogIt.new("http://qik.com/video/340982") # => Honolulu Day 8: USS Arizona at Pearl Harbor
|
246
|
+
end
|
247
|
+
should "initialize a VgQik instance" do
|
248
|
+
assert_equal "VgQik", @videotron.instance_values['object'].class.to_s
|
249
|
+
assert_equal "http://qik.com/video/340982", @videotron.instance_values['object'].instance_values['url']
|
250
|
+
assert_equal "340982", @videotron.instance_values['object'].instance_values['video_id']
|
251
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['page']
|
252
|
+
end
|
253
|
+
|
254
|
+
should "return the video properties" do
|
255
|
+
check_video_attributes({:title => "Honolulu Day 8: USS Arizona at Pearl Harbor", :service => "Qik"})
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
# ----------------------------------------------------------
|
262
|
+
# Testing www.marca.tv
|
263
|
+
# ----------------------------------------------------------
|
264
|
+
context "with a www.marca.tv video url" do
|
265
|
+
setup do
|
266
|
+
@videotron = UnvlogIt.new("http://www.marca.com/tv/?v=DN23wG8c1Rj") # => Pau entra por la puerta grande en el club de los 10.000
|
267
|
+
end
|
268
|
+
should "initialize a VgMarca instance" do
|
269
|
+
assert_equal "VgMarca", @videotron.instance_values['object'].class.to_s
|
270
|
+
assert_equal "http://www.marca.com/tv/?v=DN23wG8c1Rj", @videotron.instance_values['object'].instance_values['url']
|
271
|
+
assert_equal "DN23wG8c1Rj", @videotron.instance_values['object'].instance_values['video_id']
|
272
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['feed']
|
273
|
+
end
|
274
|
+
|
275
|
+
should "return the video properties" do
|
276
|
+
check_video_attributes({:title => "Pau entra por la puerta grande en el club de los 10.000", :service => "Marca.tv"})
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
# ----------------------------------------------------------
|
283
|
+
# Testing ted talks
|
284
|
+
# ----------------------------------------------------------
|
285
|
+
context "with a ted talks video url" do
|
286
|
+
setup do
|
287
|
+
@videotron = UnvlogIt.new("http://www.ted.com/talks/benjamin_wallace_on_the_price_of_happiness.html") # => Benjamin Wallace: Does happiness have a price tag?
|
288
|
+
end
|
289
|
+
should "initialize a VgTed instance" do
|
290
|
+
assert_equal "VgTed", @videotron.instance_values['object'].class.to_s
|
291
|
+
assert_equal "http://www.ted.com/talks/benjamin_wallace_on_the_price_of_happiness.html", @videotron.instance_values['object'].instance_values['url']
|
292
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['page']
|
293
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['flashvars']
|
294
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['args']
|
295
|
+
end
|
296
|
+
|
297
|
+
should "return the video properties" do
|
298
|
+
check_video_attributes({:title => "Benjamin Wallace: The price of happiness", :service => "Ted Talks"})
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
context "with an invalid ted talks video url" do
|
303
|
+
should "raise an ArgumentError exception" do
|
304
|
+
assert_raise(ArgumentError, "Unsuported url or service") { UnvlogIt.new("http://www.ted.com/index.php/wadus.html") }
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
|
309
|
+
# ----------------------------------------------------------
|
310
|
+
# Testing vimeo
|
311
|
+
# ----------------------------------------------------------
|
312
|
+
context "with a vimeo video url" do
|
313
|
+
setup do
|
314
|
+
@videotron = UnvlogIt.new("http://vimeo.com/2354261") # => People are strange
|
315
|
+
end
|
316
|
+
should "initialize a VgVimeo instance" do
|
317
|
+
assert_equal "VgVimeo", @videotron.instance_values['object'].class.to_s
|
318
|
+
assert_equal "http://vimeo.com/2354261", @videotron.instance_values['object'].instance_values['url']
|
319
|
+
assert_equal "2354261", @videotron.instance_values['object'].instance_values['video_id']
|
320
|
+
assert_not_nil @videotron.instance_values['object'].instance_values['feed']
|
321
|
+
end
|
322
|
+
|
323
|
+
should "return the video properties" do
|
324
|
+
check_video_attributes({:title => "People are strange", :service => "Vimeo"})
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
# ----------------------------------------------------------
|
329
|
+
# Testing RuTube
|
330
|
+
# ----------------------------------------------------------
|
331
|
+
context "with a rutube video url" do
|
332
|
+
setup do
|
333
|
+
@videotron = UnvlogIt.new("http://rutube.ru/tracks/1958807.html?v=56cd2f1b50a4d2b69ff455e72f2fae29") # => chipmunks!!
|
334
|
+
end
|
335
|
+
should "initialize a VgRutube instance" do
|
336
|
+
assert_equal "VgRutube", @videotron.instance_values['object'].class.to_s
|
337
|
+
assert_equal "http://rutube.ru/tracks/1958807.html?v=56cd2f1b50a4d2b69ff455e72f2fae29", @videotron.instance_values['object'].instance_values['url']
|
338
|
+
assert_equal "1958807", @videotron.instance_values['object'].instance_values['movie_id']
|
339
|
+
assert_equal "56cd2f1b50a4d2b69ff455e72f2fae29", @videotron.instance_values['object'].send(:movie_hash)
|
340
|
+
end
|
341
|
+
|
342
|
+
should "return the video properties" do
|
343
|
+
check_video_attributes({:title => "Запасливые бурундуки"})
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
context "with an invalid rutube video url" do
|
348
|
+
should "raise an ArgumentError exception" do
|
349
|
+
assert_raise(ArgumentError, "Unsuported url or service") { UnvlogIt.new("http://rutube.ru/tracks/abdcd.html?v=523423") }
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
# ----------------------------------------------------------
|
354
|
+
# Testing Prostopleer
|
355
|
+
# ----------------------------------------------------------
|
356
|
+
context "with a prostopleer url" do
|
357
|
+
setup do
|
358
|
+
@videotron = UnvlogIt.new("http://prostopleer.com/tracks/401758bI6n")
|
359
|
+
end
|
360
|
+
should "initialize a VgProstopleer instance" do
|
361
|
+
assert_equal "VgProstopleer", @videotron.instance_values['object'].class.to_s
|
362
|
+
assert_equal "http://prostopleer.com/tracks/401758bI6n", @videotron.instance_values['object'].instance_values['url']
|
363
|
+
assert_equal "401758bI6n", @videotron.instance_values['object'].instance_values['track_id']
|
364
|
+
assert_equal "Combichrist - sent to destroy", @videotron.title
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
context "with an invalid prostopleer url" do
|
369
|
+
should "raise an ArgumentError exception" do
|
370
|
+
assert_raise(ArgumentError) { UnvlogIt.new("http://prostopleer.com/trackszz/401758bI6n") }
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
protected
|
375
|
+
|
376
|
+
def check_video_attributes(options={})
|
377
|
+
assert_equal "#{options[:title]}", @videotron.title unless (options.blank? || options[:title].blank?)
|
378
|
+
assert_equal "#{options[:service]}", @videotron.service unless (options.blank? || options[:service].blank?)
|
379
|
+
assert_not_nil @videotron.thumbnail
|
380
|
+
if options.blank? || options[:noembed].blank?
|
381
|
+
assert_not_nil @videotron.embed_url
|
382
|
+
assert_not_nil @videotron.embed_html
|
383
|
+
elsif options[:noembed]
|
384
|
+
assert_nil @videotron.embed_url
|
385
|
+
assert_nil @videotron.embed_html
|
386
|
+
assert_nil @videotron.video_details[:embed_url]
|
387
|
+
assert_nil @videotron.video_details[:embed_html]
|
388
|
+
end
|
389
|
+
assert_not_nil @videotron.flv
|
390
|
+
assert_equal Hash, @videotron.video_details.class
|
391
|
+
end
|
392
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
$LOAD_PATH << File.dirname(__FILE__) + '/../lib'
|
5
|
+
# Main class
|
6
|
+
require 'acts_as_unvlogable'
|
7
|
+
# Gems & other herbs
|
8
|
+
require 'shoulda'
|
9
|
+
require 'ruby-debug'
|
10
|
+
|
11
|
+
class NoEmbedServiceDouble
|
12
|
+
def initialize
|
13
|
+
@details = self
|
14
|
+
end
|
15
|
+
|
16
|
+
def noembed
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ActsAsUnvlogableFactoryTest < Test::Unit::TestCase
|
22
|
+
context UnvlogIt::VideoFactory do
|
23
|
+
should "return a Vg service object" do
|
24
|
+
url = "http://vimeo.com/1234567"
|
25
|
+
service = UnvlogIt::VideoFactory.new(url).load_service
|
26
|
+
|
27
|
+
assert_equal VgVimeo, service.class
|
28
|
+
end
|
29
|
+
|
30
|
+
context "bad urls" do
|
31
|
+
should "raise an exception if no url is provided" do
|
32
|
+
assert_raise(ArgumentError) do
|
33
|
+
UnvlogIt::VideoFactory.new(nil)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# TODO this should be a NotImplementedError, but leaving as ArgumentError
|
38
|
+
# for backwards support.
|
39
|
+
should "raise an exception if we haven't implemented support for that URL" do
|
40
|
+
assert_raise(ArgumentError) do
|
41
|
+
UnvlogIt::VideoFactory.new("http://my-video-service.com/horse_apples").load_service
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
should "raise an exception if we have an invalid URL" do
|
46
|
+
# underscores are not permitted by URI::parse
|
47
|
+
assert_raise(URI::InvalidURIError) do
|
48
|
+
UnvlogIt::VideoFactory.new("http://my_video_service.com/horse_apples").load_service
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
should "raise an exception if our service object does not allow it" do
|
53
|
+
factory = UnvlogIt::VideoFactory.new("url")
|
54
|
+
|
55
|
+
# factory.stubs(:service_object).returns(service_double)
|
56
|
+
def factory.service_object
|
57
|
+
NoEmbedServiceDouble.new
|
58
|
+
end
|
59
|
+
|
60
|
+
assert_raise(ArgumentError, "Embedding disabled by request") do
|
61
|
+
factory.load_service
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_unvlogable_fork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manuel Muñoz
|
8
|
+
- Fernando Blat
|
9
|
+
- Alberto Romero
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-09-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: shoulda
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: xml-simple
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: youtube_it
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: hpricot
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
description: An easy way to include external video services in a rails app. This gem
|
72
|
+
provides you wrappers for the most common video services, such as Youtube, Vimeo,
|
73
|
+
Flickr, and so on...
|
74
|
+
email:
|
75
|
+
- mamusino@gmail.com
|
76
|
+
- ferblape@gmail.com
|
77
|
+
- denegro@gmail.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".gitignore"
|
83
|
+
- ".travis.yml"
|
84
|
+
- Gemfile
|
85
|
+
- MIT-LICENSE
|
86
|
+
- README.markdown
|
87
|
+
- Rakefile
|
88
|
+
- acts_as_unvlogable.gemspec
|
89
|
+
- lib/acts_as_unvlogable.rb
|
90
|
+
- lib/acts_as_unvlogable/flickr.rb
|
91
|
+
- lib/acts_as_unvlogable/object_base.rb
|
92
|
+
- lib/acts_as_unvlogable/string_base.rb
|
93
|
+
- lib/acts_as_unvlogable/string_extend.rb
|
94
|
+
- lib/acts_as_unvlogable/version.rb
|
95
|
+
- lib/acts_as_unvlogable/vg_11870.rb
|
96
|
+
- lib/acts_as_unvlogable/vg_blip.rb
|
97
|
+
- lib/acts_as_unvlogable/vg_collegehumor.rb
|
98
|
+
- lib/acts_as_unvlogable/vg_dailymotion.rb
|
99
|
+
- lib/acts_as_unvlogable/vg_dalealplay.rb
|
100
|
+
- lib/acts_as_unvlogable/vg_flickr.rb
|
101
|
+
- lib/acts_as_unvlogable/vg_marca.rb
|
102
|
+
- lib/acts_as_unvlogable/vg_metacafe.rb
|
103
|
+
- lib/acts_as_unvlogable/vg_myspace.rb
|
104
|
+
- lib/acts_as_unvlogable/vg_prostopleer.rb
|
105
|
+
- lib/acts_as_unvlogable/vg_qik.rb
|
106
|
+
- lib/acts_as_unvlogable/vg_rutube.rb
|
107
|
+
- lib/acts_as_unvlogable/vg_ted.rb
|
108
|
+
- lib/acts_as_unvlogable/vg_vimeo.rb
|
109
|
+
- lib/acts_as_unvlogable/vg_youtu.rb
|
110
|
+
- lib/acts_as_unvlogable/vg_youtube.rb
|
111
|
+
- test/acts_as_unvlogable_test.rb
|
112
|
+
- test/video_factory_test.rb
|
113
|
+
- unvlogable_sample.yml
|
114
|
+
homepage: https://github.com/mamuso/acts_as_unvlogable
|
115
|
+
licenses: []
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project: acts_as_unvlogable
|
133
|
+
rubygems_version: 2.4.1
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: An easy way to include external video services in a rails app
|
137
|
+
test_files: []
|