require File.dirname(__FILE__) + '/../unit_test_helper'
class LinkTest < Test::Unit::TestCase
def test_transform
result = auto_html("http://vukajlija.com") { link }
assert_equal 'http://vukajlija.com', result
end
def test_transform_with_the_slash_at_the_end
result = auto_html("http://github.com/") { link }
assert_equal 'http://github.com/', result
end
def test_transform_with_param
result = auto_html('http://example.com/abc?query=ruby') { link }
assert_equal 'http://example.com/abc?query=ruby', result
end
def test_transform_with_param_and_trailing_dot
result = auto_html('http://example.com/abc?query=ruby.') { link }
assert_equal 'http://example.com/abc?query=ruby.', result
end
def test_transform_with_anchor_and_trailing_dot
result = auto_html('http://example.com/example#id=123.12.') { link }
assert_equal 'http://example.com/example#id=123.12.', result
end
def test_transform_with_params
result = auto_html('http://www.youtube.com/watch?v=s5C5Zk4kobo&feature=related') { link }
assert_equal 'http://www.youtube.com/watch?v=s5C5Zk4kobo&feature=related', result
end
def test_transform_with_commas
result = auto_html('http://www.dw-world.de/dw/article/0,,4708386,00.html?maca=ser-rss-ser-all-1494-rdf') { link }
assert_equal 'http://www.dw-world.de/dw/article/0,,4708386,00.html?maca=ser-rss-ser-all-1494-rdf', result
end
def test_transform_complex_url
result = auto_html("http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0") { link }
assert_equal 'http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0', result
end
def test_transform_with_options
result = auto_html("http://rors.org") { link :rel => "nofollow", :target => "_blank" }
assert_equal 'http://rors.org', result
end
end