]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/howcast_test.rb
Fix a missing slash.
[dead/whatever-dl.git] / test / howcast_test.rb
1 #
2 # Copyright Michael Orlitzky
3 #
4 # http://michael.orlitzky.com/
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # http://www.fsf.org/licensing/licenses/gpl.html
17 #
18
19 require 'test/unit'
20 require 'src/websites/howcast'
21
22 # Unit tests for the Howcast class.
23 # This class is easy because get_video_url is
24 # just a string interpolation (we don't have to
25 # test that).
26
27 class HowcastTest < Test::Unit::TestCase
28
29 def test_owns_howcast_urls
30 assert(Howcast.owns_url?('http://www.howcast.com/videos/6807-2twr'))
31 assert(Howcast.owns_url?('www.howcast.com/videos/6807-2dgfdg'))
32 assert(Howcast.owns_url?('http://howcast.com/videos/6807-cse'))
33 assert(Howcast.owns_url?('howcast.com/videos/6807-asdgasd'))
34 end
35
36
37 def test_doesnt_own_redtube_urls
38 assert(!Howcast.owns_url?('http://www.redtube.com/6807'))
39 assert(!Howcast.owns_url?('www.redtube.com/6807'))
40 assert(!Howcast.owns_url?('http://redtube.com/6807'))
41 assert(!Howcast.owns_url?('redtube.com/6807'))
42 end
43
44
45 def test_doesnt_own_misc_urls
46 assert(!Howcast.owns_url?('http://www.howcast.com/abc'))
47 end
48
49
50 def test_parse_file_path_from_xml
51 hc = Howcast.new(nil)
52
53 page_data = nil
54
55 File.open('test/fixtures/howcast/81134.xml') do |f|
56 page_data = f.read
57 end
58
59 test_result = hc.send('parse_file_path_from_xml', page_data)
60 assert_equal('/system/videos/4/34/11/08/81134.flv', test_result)
61 end
62
63 end