end
- def test_parse_t_parameter
- yt = Youtube.new(nil)
-
- page_data = nil
-
- File.open('test/fixtures/youtube/SudixyugiX4.html') do |f|
- page_data = f.read
- end
-
- expected_result = 'OEgsToPDskLQUAntWWpzhEMhBMlgqHdo'
- actual_result = yt.send('parse_t_parameter', page_data)
- assert_equal(expected_result, actual_result)
- end
-
-
- def test_parse_t_parameter_again
- # This was failing once because my regex missed a hyphen.
- # I modified the regex to match anything between the pair
- # of quotes, so it should now catch the hyphen and underscore.
- yt = Youtube.new(nil)
-
- page_data = nil
-
- File.open('test/fixtures/youtube/K9iDMcmm0tE.html') do |f|
- page_data = f.read
- end
-
- expected_result = 'O_EgsToPDskJsXVvAXpAct1zug-lBJBz'
- actual_result = yt.send('parse_t_parameter', page_data)
- assert_equal(expected_result, actual_result)
- end
-
-
- def test_parse_t_parameter_from_url
- # Tests a different regex than the other 't' parameter tests.
- yt = Youtube.new(nil)
-
- page_data = nil
-
- File.open('test/fixtures/youtube/cpU27Xp8zdM.html') do |f|
- page_data = f.read
- end
-
- expected_result = 'vjVQa1PpcFNyKz8nP3yZ3MHcwOvLXsOWpCJHkgJVShI='
- actual_result = yt.send('parse_t_parameter', page_data)
- assert_equal(expected_result, actual_result)
- end
-
-
def test_get_available_formats
# Make sure that we can parse the available formats from a page.
yt = Youtube.new(nil)