Class: URITest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- URITest
- Includes:
- ChunkMatch
- Defined in:
- app/models/chunks/uri_test.rb
Instance Method Summary collapse
- #test_email_uri ⇒ Object
- #test_non_email ⇒ Object
- #test_non_matches ⇒ Object
- #test_non_uri ⇒ Object
- #test_simple_uri ⇒ Object
- #test_uri_in_parentheses ⇒ Object
- #test_uri_in_text ⇒ Object
- #test_uri_list_item ⇒ Object
Methods included from ChunkMatch
Instance Method Details
#test_email_uri ⇒ Object
51 52 53 54 55 |
# File 'app/models/chunks/uri_test.rb', line 51 def test_email_uri match(URIChunk, '[email protected]', :user => 'mail', :host => 'example.com', :link_text => '[email protected]' ) end |
#test_non_email ⇒ Object
57 58 59 60 |
# File 'app/models/chunks/uri_test.rb', line 57 def test_non_email # The @ is part of the normal text, but 'example.com' is marked up. match(URIChunk, 'Not an email: @example.com', :user => nil, :uri => 'http://example.com') end |
#test_non_matches ⇒ Object
8 9 10 11 |
# File 'app/models/chunks/uri_test.rb', line 8 def test_non_matches assert_no_match(URIChunk.pattern, 'There is no URI here') assert_no_match(URIChunk.pattern, 'One gemstone is the garnet:reddish in colour, like ruby') end |
#test_non_uri ⇒ Object
62 63 64 65 |
# File 'app/models/chunks/uri_test.rb', line 62 def test_non_uri assert_no_match(URIChunk.pattern, 'httpd.conf') assert_no_match(URIChunk.pattern, 'libproxy.so') end |
#test_simple_uri ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/chunks/uri_test.rb', line 13 def test_simple_uri match(URIChunk, 'http://www.example.com', :scheme =>'http', :host =>'www.example.com', :path => nil, :link_text => 'http://www.example.com' ) match(URIChunk, 'http://www.example.com/', :scheme =>'http', :host =>'www.example.com', :path => '/', :link_text => 'http://www.example.com/' ) match(URIChunk, 'www.example.com', :scheme =>'http', :host =>'www.example.com', :link_text => 'www.example.com' ) match(URIChunk, 'example.com', :scheme =>'http',:host =>'example.com', :link_text => 'example.com' ) match(URIChunk, 'http://example.com.au/', :scheme =>'http', :host =>'example.com.au', :link_text => 'http://example.com.au/' ) match(URIChunk, 'example.com.au', :scheme =>'http', :host =>'example.com.au', :link_text => 'example.com.au' ) match(URIChunk, 'http://www.example.co.uk/', :scheme =>'http', :host =>'www.example.co.uk', :link_text => 'http://www.example.co.uk/' ) match(URIChunk, 'example.co.uk', :scheme =>'http', :host =>'example.co.uk', :link_text => 'example.co.uk' ) match(URIChunk, 'http://moinmoin.wikiwikiweb.de/HelpOnNavigation', :scheme => 'http', :host => 'moinmoin.wikiwikiweb.de', :path => '/HelpOnNavigation', :link_text => 'http://moinmoin.wikiwikiweb.de/HelpOnNavigation' ) match(URIChunk, 'moinmoin.wikiwikiweb.de/HelpOnNavigation', :scheme => 'http', :host => 'moinmoin.wikiwikiweb.de', :path => '/HelpOnNavigation', :link_text => 'moinmoin.wikiwikiweb.de/HelpOnNavigation' ) end |
#test_uri_in_parentheses ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'app/models/chunks/uri_test.rb', line 76 def test_uri_in_parentheses match(URIChunk, 'URI (http://brackets.com.de) in brackets', :host => 'brackets.com.de') match(URIChunk, 'because (as shown at research.net) the results', :host => 'research.net') match(URIChunk, 'A wiki (http://wiki.org/wiki.cgi?WhatIsWiki) page', :scheme => 'http', :host => 'wiki.org', :path => '/wiki.cgi', :query => 'WhatIsWiki' ) end |
#test_uri_in_text ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'app/models/chunks/uri_test.rb', line 67 def test_uri_in_text match(URIChunk, 'Go to: http://www.example.com/', :host => 'www.example.com', :path =>'/') match(URIChunk, 'http://www.example.com/ is a link.', :host => 'www.example.com') match(URIChunk, 'Email [email protected]', :scheme =>'mailto', :user =>'david', :host =>'loudthinking.com' ) end |
#test_uri_list_item ⇒ Object
85 86 87 88 89 90 91 |
# File 'app/models/chunks/uri_test.rb', line 85 def test_uri_list_item match( URIChunk, '* http://www.btinternet.com/~mail2minh/SonyEricssonP80xPlatform.sis', :path => '/~mail2minh/SonyEricssonP80xPlatform.sis' ) end |