Skip to content

Instantly share code, notes, and snippets.

@TheNotary
Created April 1, 2013 23:32
Show Gist options
  • Save TheNotary/5288676 to your computer and use it in GitHub Desktop.
Save TheNotary/5288676 to your computer and use it in GitHub Desktop.
def test_youtube_parser
url1 = "http://www.youtube.com/watch?v=E4Fbk52Mk1w"
just_an_id = 'E4Fbk52Mk1w'
url_without_http = "www.youtube.com/watch?v=E4Fbk52Mk1w"
url_without_www = "youtube.com/watch?v=E4Fbk52Mk1w"
url_with_feature = "http://www.youtube.com/watch?feature=player_embedded&v=E4Fbk52Mk1w"
expected_output = 'E4Fbk52Mk1w'
assert_equal expected_output,
RubyBBCode.parse_youtube_id(url1)
assert_equal expected_output,
RubyBBCode.parse_youtube_id(just_an_id)
assert_equal expected_output,
RubyBBCode.parse_youtube_id(url_without_http)
assert_equal expected_output,
RubyBBCode.parse_youtube_id(url_without_www)
assert_equal expected_output,
RubyBBCode.parse_youtube_id(url_with_feature)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment