# # Copyright Michael Orlitzky # # http://michael.orlitzky.com/ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # http://www.fsf.org/licensing/licenses/gpl.html # require 'test/unit' require 'whatever-dl/websites/efukt' class EfuktTest < Test::Unit::TestCase def test_owns_efukt_urls assert(Efukt.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html')) assert(Efukt.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html')) end def test_doesnt_own_infoq_urls assert(!Efukt.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake')) end def test_get_video_filename_works_on_good_urls ef = Efukt.new('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html') expected_filename = '2308_How_To_Fuck_Like_A_King.flv' actual_filename = ef.get_video_filename() assert_equal(expected_filename, actual_filename) end def test_get_video_filename_works_on_weird_urls # The regex looks for an html extension, so this should # not match. Instead, it should fall back on everything # between the final slash and that last period. In this # case, the filename should be the same as if the extension # were html. ef = Efukt.new('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.broken') expected_filename = '2308_How_To_Fuck_Like_A_King.flv' actual_filename = ef.get_video_filename() assert_equal(expected_filename, actual_filename) end end