Class: TestLinkResolver
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TestLinkResolver
- Defined in:
- lib/html2email/vendor/premailer/tests/test_link_resolver.rb
Instance Method Summary collapse
- #test_resolving_urls_from_string ⇒ Object
- #test_resolving_urls_from_uri ⇒ Object
- #test_resolving_urls_in_doc ⇒ Object
Instance Method Details
#test_resolving_urls_from_string ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/html2email/vendor/premailer/tests/test_link_resolver.rb', line 4 def test_resolving_urls_from_string ['test.html', '/test.html', './test.html', 'test/../test.html', 'test/../test/../test.html'].each do |q| assert_equal 'http://example.com/test.html', Premailer.resolve_link(q, 'http://example.com/'), q end assert_equal 'https://example.net:80/~basedir/test.html?var=1#anchor', Premailer.resolve_link('test/../test/../test.html?var=1#anchor', 'https://example.net:80/~basedir/') end |
#test_resolving_urls_from_uri ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/html2email/vendor/premailer/tests/test_link_resolver.rb', line 13 def test_resolving_urls_from_uri base_uri = URI.parse('http://example.com/') ['test.html', '/test.html', './test.html', 'test/../test.html', 'test/../test/../test.html'].each do |q| assert_equal 'http://example.com/test.html', Premailer.resolve_link(q, base_uri), q end base_uri = URI.parse('https://example.net:80/~basedir/') assert_equal 'https://example.net:80/~basedir/test.html?var=1#anchor', Premailer.resolve_link('test/../test/../test.html?var=1#anchor', base_uri) # base URI with a query string base_uri = URI.parse('http://example.com/dir/index.cfm?newsletterID=16') assert_equal 'http://example.com/dir/index.cfm?link=15', Premailer.resolve_link('?link=15', base_uri) # URI preceded by a space base_uri = URI.parse('http://example.com/') assert_equal 'http://example.com/path', Premailer.resolve_link(' path', base_uri) end |
#test_resolving_urls_in_doc ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/html2email/vendor/premailer/tests/test_link_resolver.rb', line 32 def test_resolving_urls_in_doc base_file = File.dirname(__FILE__) + '/files/base.html' base_url = 'https://my.example.com:8080/test-path.html' premailer = Premailer.new(base_file, :base_url => base_url) premailer.to_inline_css pdoc = premailer.processed_doc doc = premailer.doc # unchanged links ['#l02', '#l03', '#l05', '#l06', '#l07', '#l08', '#l09', '#l10', '#l11', '#l12', '#l13'].each do |link_id| assert_equal doc.at(link_id).attributes['href'], pdoc.at(link_id).attributes['href'], link_id end assert_equal 'https://my.example.com:8080/', pdoc.at('#l01').attributes['href'] assert_equal 'https://my.example.com:8080/images/', pdoc.at('#l04').attributes['href'] end |