Class: TestPremailer
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TestPremailer
- Includes:
- WEBrick
- Defined in:
- lib/html2email/vendor/premailer/tests/test_premailer.rb
Instance Method Summary collapse
- #test_accents ⇒ Object
- #test_escaping_strings ⇒ Object
- #test_importing_local_css ⇒ Object
- #test_importing_remote_css ⇒ Object
- #test_merging_cellpadding ⇒ Object
- #test_preserving_media_queries ⇒ Object
- #test_related_attributes ⇒ Object
Instance Method Details
#test_accents ⇒ Object
7 8 9 10 11 |
# File 'lib/html2email/vendor/premailer/tests/test_premailer.rb', line 7 def test_accents local_setup assert_equal 'cédille cé garçon garçon à à', @doc.at('#accents').inner_html end |
#test_escaping_strings ⇒ Object
13 14 15 16 17 18 |
# File 'lib/html2email/vendor/premailer/tests/test_premailer.rb', line 13 def test_escaping_strings local_setup str = %q{url("/images/test.png");} assert_equal("url(\'/images/test.png\');", Premailer.escape_string(str)) end |
#test_importing_local_css ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/html2email/vendor/premailer/tests/test_premailer.rb', line 20 def test_importing_local_css flunk local_setup # noimport.css (print stylesheet) sets body { background } to red assert_no_match /red/, @doc.at('body').attributes['style'] # import.css sets .hide to { display: none } assert_match /display: none/, @doc.at('#hide01').attributes['style'] end |
#test_importing_remote_css ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/html2email/vendor/premailer/tests/test_premailer.rb', line 31 def test_importing_remote_css flunk remote_setup # noimport.css (print stylesheet) sets body { background } to red assert_no_match /red/, @doc.at('body').attributes['style'] # import.css sets .hide to { display: none } assert_match /display: none/, @doc.at('#hide01').attributes['style'] end |
#test_merging_cellpadding ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/html2email/vendor/premailer/tests/test_premailer.rb', line 65 def test_merging_cellpadding flunk local_setup('cellpadding.html', {:prefer_cellpadding => true}) assert_equal '0', @doc.at('#t1')['cellpadding'] assert_match /padding\:/i, @doc.at('#t1 td')['style'] assert_equal '5', @doc.at('#t2')['cellpadding'] assert_no_match /padding\:/i, @doc.at('#t2 td')['style'] assert_nil @doc.at('#t3')['cellpadding'] assert_match /padding\:/i, @doc.at('#t3 td')['style'] assert_nil @doc.at('#t4')['cellpadding'] assert_match /padding\:/i, @doc.at('#t4a')['style'] assert_match /padding\:/i, @doc.at('#t4b')['style'] end |
#test_preserving_media_queries ⇒ Object
82 83 84 85 |
# File 'lib/html2email/vendor/premailer/tests/test_premailer.rb', line 82 def test_preserving_media_queries local_setup assert_match /display\: none/i, @doc.at('#iphone')['style'] end |
#test_related_attributes ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/html2email/vendor/premailer/tests/test_premailer.rb', line 43 def local_setup # h1 { text-align: center; } assert_equal 'center', @doc.at('h1')['align'] # td { vertical-align: top; } assert_equal 'top', @doc.at('td')['valign'] # p { vertical-align: top; } -- not allowed assert_nil @doc.at('p')['valign'] # no align attr is specified for <p> elements, so it should not appear assert_nil @doc.at('p.unaligned')['align'] # .contact { background: #9EC03B url("contact_bg.png") repeat 0 0; } assert_equal '#9EC03B', @doc.at('td.contact')['bgcolor'] # body { background-color: #9EBF00; } assert_equal '#9EBF00', @doc.at('body')['bgcolor'] end |