Module: Texta::Etest
- Defined in:
- lib/texta.rb
Instance Method Summary collapse
- #_test_list ⇒ Object
- #assert_equal_xml(x1, x2) ⇒ Object
- #assert_testa(input, text, html) ⇒ Object
- #test_anchor ⇒ Object
- #test_complicated ⇒ Object
- #test_entities ⇒ Object
- #test_img ⇒ Object
- #test_invalid_option ⇒ Object
- #test_link ⇒ Object
- #test_nil ⇒ Object
-
#test_plain_text ⇒ Object
Tests are “<input>, ”<text>“, ”<output>“”.
- #test_string_module ⇒ Object
- #test_t1 ⇒ Object
- #test_table ⇒ Object
Instance Method Details
#_test_list ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/texta.rb', line 168 def _test_list input = "Information\n\n- Full-HD\n- Aufl\u00F6sung: 1920 x 1080 \n- Format: 16:9 \n\nDie Ware wird originalverpackt und mit dem vom Hersteller beschriebenen Zubeh\u00F6r an Sie ausgeliefert.\n" text = "Information\n\n- Full-HD\n- Aufl\u00F6sung: 1920 x 1080 \n- Format: 16:9 \n\nDie Ware wird originalverpackt und mit dem vom Hersteller beschriebenen Zubeh\u00F6r an Sie ausgeliefert.\n" html = "<p>Information</p>\n<ul>\n<li>Full-HD</li>\n <li>Auflösung: 1920 x 1080</li>\n <li>Format: 16:9</li>\n</ul> \n<p>\nDie Ware wird originalverpackt und mit dem vom Hersteller beschriebenen Zubehör an Sie ausgeliefert.\n</p>\n" assert_testa input, text, html end |
#assert_equal_xml(x1, x2) ⇒ Object
139 140 141 142 143 |
# File 'lib/texta.rb', line 139 def assert_equal_xml(x1, x2) return if x1 == x2 return if x1.to_s.gsub(/\s/, "") == x2.to_s.gsub(/\s/, "") assert_equal(x1 ,x2) end |
#assert_testa(input, text, html) ⇒ Object
145 146 147 148 |
# File 'lib/texta.rb', line 145 def assert_testa(input, text, html) assert_equal text || input, input.texta(:text) assert_equal_xml html, input.texta(:html) end |
#test_anchor ⇒ Object
300 301 302 303 304 305 |
# File 'lib/texta.rb', line 300 def test_anchor input = "<a name='anchor'>test</a>ho!" html = '<p>ho!</p>' text = "\nho!" assert_testa input, text, html end |
#test_complicated ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/texta.rb', line 312 def test_complicated input = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> \n<meta content=\"Word.Document\" name=\"ProgId\" /> \n<meta content=\"Microsoft Word 12\" name=\"Generator\" /> \n<meta content=\"Microsoft Word 12\" name=\"Originator\" /> \n<div style=\"TEXT-ALIGN: justify\" align=\"justify\"> \n<link href=\"file:///C:%5CUsers%5CStefan%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml\" rel=\"File-List\" /> \n<link href=\"file:///C:%5CUsers%5CStefan%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx\" rel=\"themeData\" /> \n<link href=\"file:///C:%5CUsers%5CStefan%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml\" rel=\"colorSchemeMapping\" />\n<style type=\"text/css\"> <!-- /* Font Definitions */ @font-face {\"Cambria Math\"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {\"Arial Unicode MS\"; panose-1:2 11 6 4 2 2 2 2 2 4;} @font-face { panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {\"\\@Arial Unicode MS\"; panose-1:2 11 6 4 2 2 2 2 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal { mso-style-parent:\"\"; margin-top:12.0pt; margin-right:0cm; margin-bottom:0cm; margin-left:0cm; margin-bottom:.0001pt; line-height:5%; font-size:11.0pt;\"Calibri\",\"sans-serif\"; mso-bidi-\"Times New Roman\";} .MsoChpDefault { mso-bidi-\"Times New Roman\";} .MsoPapDefault { margin-top:12.0pt; line-height:5%;} @page Section1 {size:595.3pt 841.9pt; margin:70.85pt 70.85pt 2.0cm 70.85pt;} div.Section1 {page:Section1;} --></style>\n<span style=\"FONT-FAMILY: Arial\">Das T-Shirt „Che“ der Streetwear Marke Exact Science ist eine Hommage an den Revolutionär Che Guevara. Tausende T-Shirts wurden bereits mit seinem Abbild gedruckt, doch keines traf bisher unseren Geschmack so wie das T-Shirt „Che“ von Exact Science.Genauso revolutionär wie Che‘s Unabhängigkeitsbewegung, gestaltet auch Exact Science ihre Motive und gelten deshalb als Vorreiter der T-Shirt Zunft. Die Perfekte Kombination aus Kunst und Geschichte. urban-stylistics sagt: „Danke“</span> <br style=\"FONT-FAMILY: Arial\" /><span style=\"FONT-FAMILY: Arial\">Unser Model ist 184 cm groß und trägt die Größe M.</span><br style=\"FONT-FAMILY: Arial\" /></div> \n<p align=\"justify\"><span style=\"FONT-FAMILY: Arial\">100 % Baumwolle</span><br /><br /><a href=\"http://www.urban-stylistics.com/Marken-Mann/Exact-Science:::47_37.html\" target=\"_self\"><img height=\"67\" alt=\"\" src=\"/images/Logos Marken/xs_logo.gif\" width=\"67\" /></a></p>\n" text = " Das T-Shirt \u201EChe\u201C der Streetwear Marke Exact Science ist eine Hommage an den Revolution\u00E4r Che Guevara. Tausende T-Shirts wurden bereits mit seinem Abbild gedruckt, doch keines traf bisher unseren Geschmack so wie das T-Shirt \u201EChe\u201C von Exact Science.Genauso revolution\u00E4r wie Che\u2018s Unabh\u00E4ngigkeitsbewegung, gestaltet auch Exact Science ihre Motive und gelten deshalb als Vorreiter der T-Shirt Zunft. Die Perfekte Kombination aus Kunst und Geschichte. urban-stylistics sagt: \u201EDanke\u201C \n Unser Model ist 184 cm gro\u00DF und tr\u00E4gt die Gr\u00F6\u00DFe M. \n\n\n100 % Baumwolle \n \n \n" html = "<pre><code>Das T-Shirt &bdquo;Che&ldquo; der Streetwear Marke Exact Science ist eine Hommage an den Revolution&auml;r Che Guevara. Tausende T-Shirts wurden bereits mit seinem Abbild gedruckt, doch keines traf bisher unseren Geschmack so wie das T-Shirt &bdquo;Che&ldquo; von Exact Science.Genauso revolution&auml;r wie Che&lsquo;s Unabh&auml;ngigkeitsbewegung, gestaltet auch Exact Science ihre Motive und gelten deshalb als Vorreiter der T-Shirt Zunft. Die Perfekte Kombination aus Kunst und Geschichte. urban-stylistics sagt: &bdquo;Danke&ldquo; \n</code></pre>\n\n<p> Unser Model ist 184 cm groß und trägt die Größe M.</p>\n\n<p>100 % Baumwolle</p>\n" assert_testa input, text, html end |
#test_entities ⇒ Object
159 160 161 162 163 164 165 166 |
# File 'lib/texta.rb', line 159 def test_entities input = "ÄÖÜäöü" html = "html" text = "ÄÖÜäöü" html = "<p>ÄÖÜäöü</p>" assert_testa input, text, html end |
#test_img ⇒ Object
307 308 309 310 |
# File 'lib/texta.rb', line 307 def test_img input = "<img src='http://x/y/z.jpg' />" assert_testa input, "", "" end |
#test_invalid_option ⇒ Object
208 209 210 211 212 |
# File 'lib/texta.rb', line 208 def test_invalid_option assert_raise(NoMethodError) { "ss".texta(:x) } end |
#test_link ⇒ Object
293 294 295 296 297 298 |
# File 'lib/texta.rb', line 293 def test_link input = "<a href='http://google.com'>Link</a>" html = '' text = "" assert_testa input, text, html end |
#test_nil ⇒ Object
247 248 249 |
# File 'lib/texta.rb', line 247 def test_nil assert_testa nil, nil, nil end |
#test_plain_text ⇒ Object
Tests are “<input>, ”<text>“, ”<output>“”
151 152 153 154 155 156 157 |
# File 'lib/texta.rb', line 151 def test_plain_text input = "XYZ" text = "XYZ" html = "<p>XYZ</p>" assert_testa input, text, html end |
#test_string_module ⇒ Object
204 205 206 |
# File 'lib/texta.rb', line 204 def test_string_module assert_equal "a **chd** d\n", "a <b>chd</b> d".texta(:text) end |
#test_t1 ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/texta.rb', line 214 def test_t1 input = "<p>\nRead this book!\n</p>\n<ul>\n<li>All you ever wanted to know about html!</li>\n<li>and even more</li>\n<li>at your fingertips</li>\n</ul>\n" text = "Read this book!\n\n- All you ever wanted to know about html!\n- and even more\n- at your fingertips\n\n" html = "<p>Read this book!</p>\n<ul>\n<li>All you ever wanted to know about html!</li>\n<li>and even more</li>\n<li>at your fingertips</li>\n</ul>\n" assert_testa input, text, html end |
#test_table ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/texta.rb', line 251 def test_table input = "<table><tr>\n<th>Farben</th>\n<td>halbtransparent, halbtransparent blau (Polycarbonat)</td>\n</tr>\n<tr>\n<th>Material</th>\n<td>K\u00F6rper und Fl\u00FCgel aus Polycarbonat</td>\n</tr>\n<tr>\n<th>Abmessungen</th>\n<td>\n <u>H\u00F6he</u>: 44cm<br>\n <u>Durchmesser</u>: 122cm<br>\n</td>\n</tr>\n<tr><th>Sonstiges</th><td>Steuerung \u00FCber Fernbedienung</td></tr>\n</table>\n" text = "**Farben** halbtransparent, halbtransparent blau (Polycarbonat)\n**Material** K\u00F6rper und Fl\u00FCgel aus Polycarbonat\n**Abmessungen** H\u00F6he : 44cm \n Durchmesser : 122cm \n\n**Sonstiges** Steuerung \u00FCber Fernbedienung\n" html = "<p><strong>Farben</strong> halbtransparent, halbtransparent blau (Polycarbonat)\n <strong>Material</strong> Körper und Flügel aus Polycarbonat\n <strong>Abmessungen</strong> Höhe : 44cm\n Durchmesser : 122cm</p>\n\n<p> <strong>Sonstiges</strong> Steuerung über Fernbedienung</p>\n" assert_testa input, text, html end |