# -*- encoding : utf-8 -*- describe Card::Content::Chunk::URI, 'URI chunk tests' do it 'should test_non_matches' do no_match_uri 'There is no URI here' no_match_uri 'One gemstone is the garnet:reddish in colour, like ruby' end it 'works with simple uri' do # Simplest case match_http_uri 'http://www.example.com', host: 'www.example.com', path: '' end it 'works with trailing slash' do match_http_uri 'http://www.example.com/', host: 'www.example.com', path: '/' end it 'works with trailing slash inside html tags' do match_http_uri '
http://www.example.com/
', host: 'www.example.com', path: '/', link_text: 'http://www.example.com/' end it 'works with trailing period (no longer suppressed .. spec?)' do match_http_uri 'http://www.example.com/. ', host: 'www.example.com', path: '/', link_text: 'http://www.example.com/' end it 'works with trailing period inside html tags (dot change?)' do match_http_uri 'http://www.example.com/.
', host: 'www.example.com', path: '/', link_text: 'http://www.example.com/' end it 'works with trailing ' do match_http_uri 'http://www.example.com/ ', host: 'www.example.com', path: '/', link_text: 'http://www.example.com/' end it 'works without http://' do match_http_uri 'www.example.com', host: 'www.example.com', text: 'www.example.com', link_text: 'http://www.example.com' match_http_uri 'example.com', host: 'example.com', text: 'example.com', link_text: 'http://example.com' end it 'should match "unusual" base domain (was a bug in an early version)' do match_http_uri 'http://example.com.au/', host: 'example.com.au' end it 'works with "unusual" base domain without http://' do match_http_uri 'example.com.au', host: 'example.com.au', text: 'example.com.au', link_text: 'http://example.com.au' end it 'works with another "unusual" base domain' do match_http_uri 'http://www.example.co.uk/', host: 'www.example.co.uk' match_http_uri 'example.co.uk', host: 'example.co.uk', text: 'example.co.uk', link_text: 'http://example.co.uk' end it 'works with some path at the end' do match_http_uri 'http://moinmoin.wikiwikiweb.de/HelpOnNavigation', host: 'moinmoin.wikiwikiweb.de', path: '/HelpOnNavigation' end it 'works with some path at the end, and without http:// prefix (@link_text has prefix added)' do match_http_uri 'moinmoin.wikiwikiweb.de/HelpOnNavigation', host: 'moinmoin.wikiwikiweb.de', path: '/HelpOnNavigation', text: 'moinmoin.wikiwikiweb.de/HelpOnNavigation', link_text: 'http://moinmoin.wikiwikiweb.de/HelpOnNavigation' end it 'works with a port number' do match_http_uri 'http://www.example.com:80', host: 'www.example.com', port: 80, path: '' end it 'works with a port number and a path' do match_http_uri 'http://www.example.com.tw:80/HelpOnNavigation', host: 'www.example.com.tw', port: 80, path: '/HelpOnNavigation' end it 'works with a query' do match_http_uri 'http://www.example.com.tw:80/HelpOnNavigation?arg=val', host: 'www.example.com.tw', port: 80, path: '/HelpOnNavigation', query: 'arg=val' end it 'works on Query with two arguments' do match_http_uri 'http://www.example.com.tw:80/HelpOnNavigation?arg=val&arg2=val2', host: 'www.example.com.tw', port: 80, path: '/HelpOnNavigation', query: 'arg=val&arg2=val2' end it 'works with IRC' do match_uri 'irc://irc.freenode.net#recentchangescamp', scheme: 'irc', host: 'irc.freenode.net', fragment: 'recentchangescamp', link_text: 'irc://irc.freenode.net#recentchangescamp' end it 'should see HTTPS' do match_uri 'https://www.example.com', scheme: 'https', host: 'www.example.com', port: 443, path: '', query: nil end it 'should see FTP' do match_uri 'ftp://www.example.com', scheme: 'ftp', host: 'www.example.com', port: 21, path: '', query: nil end it 'should handle mailto:' do match_uri 'mailto:jdoe123@example.com', scheme: 'mailto', host: nil, port: nil, path: nil, query: nil, to: 'jdoe123@example.com' end it 'should run more basic cases' do # from *css (with () around the URI) # so, now this doesn't even match because I fixed the suspiciou* stuff no_match_uri( "background: url('http://dl.dropbox.com/u/4657397/wikirate/" \ "wikirate_files/wr-bg-menu-line.gif') repeat-x;" ) # Soap opera (the most complex case imaginable... well, not really, there # should be more evil) match_http_uri( 'http://www.example.com.tw:80/~jdoe123/Help%20Me%20?arg=val&arg2=val2', host: 'www.example.com.tw', port: 80, path: '/~jdoe123/Help%20Me%20', query: 'arg=val&arg2=val2') # from 0.9 bug reports match_uri 'http://www2.pos.to/~tosh/ruby/rdtool/en/doc/rd-draft.html', scheme: 'http', host: 'www2.pos.to', path: '/~tosh/ruby/rdtool/en/doc/rd-draft.html' match_uri 'http://support.microsoft.com/default.aspx?scid=kb;en-us;234562', scheme: 'http', host: 'support.microsoft.com', path: '/default.aspx', query: 'scid=kb;en-us;234562' end it 'should test_email_uri' do match_uri 'mail@example.com', to: 'mail@example.com', host: nil, text: 'mail@example.com', link_text: 'mailto:mail@example.com' end it 'should test_non_email' do # The @ is part of the normal text, but 'example.com' is marked up. match_uri 'Not an email: @example.com', uri: 'http://example.com' end it 'should test_textile_image' do no_match_uri 'This !http://hobix.com/sample.jpg! is a Textile image link.' end it 'should test_textile_link' do no_match_uri( 'This "hobix (hobix)":http://hobix.com/sample.jpg is a Textile link.' ) # just to be sure ... match_uri 'This http://hobix.com/sample.jpg should match', link_text: 'http://hobix.com/sample.jpg' end it 'should test_inline_html' do no_match_uri "