Module: Texta::Etest

Defined in:
lib/texta.rb

Instance Method Summary collapse

Instance Method Details

#_test_listObject



160
161
162
163
164
165
166
167
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
# File 'lib/texta.rb', line 160

def _test_list
  input = <<TXT
Information

- Full-HD
- Auflösung: 1920 x 1080 
- Format: 16:9 

Die Ware wird originalverpackt und mit dem vom Hersteller beschriebenen Zubehör an Sie ausgeliefert.
TXT

  text = <<TEXT
Information

- Full-HD
- Auflösung: 1920 x 1080 
- Format: 16:9 

Die Ware wird originalverpackt und mit dem vom Hersteller beschriebenen Zubehör an Sie ausgeliefert.
TEXT

  html = <<HTML
<p>Information</p>
<ul>
<li>Full-HD</li>
 <li>Aufl&ouml;sung: 1920 x 1080</li>
 <li>Format: 16:9</li>
</ul> 
<p>
Die Ware wird originalverpackt und mit dem vom Hersteller beschriebenen Zubeh&ouml;r an Sie ausgeliefert.
</p>
HTML

  assert_testa input, text, html
end

#assert_equal_xml(x1, x2) ⇒ Object



131
132
133
134
135
# File 'lib/texta.rb', line 131

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



137
138
139
140
# File 'lib/texta.rb', line 137

def assert_testa(input, text, html)
  assert_equal text || input, input.texta(:text)
  assert_equal_xml html, input.texta(:html)
end

#test_anchorObject



292
293
294
295
296
297
# File 'lib/texta.rb', line 292

def test_anchor
  input = "<a name='anchor'>test</a>ho!"
  html = '<p>ho!</p>'
  text = "\nho!"
  assert_testa input, text, html
end

#test_entitiesObject



151
152
153
154
155
156
157
158
# File 'lib/texta.rb', line 151

def test_entities
  input = "ÄÖÜäöü"
  html = "html"
  text = "ÄÖÜäöü"
  html = "<p>&Auml;&Ouml;&Uuml;&auml;&ouml;&uuml;</p>"
  
  assert_testa input, text, html
end

#test_imgObject



299
300
301
302
# File 'lib/texta.rb', line 299

def test_img
  input = "<img src='http://x/y/z.jpg' />"
  assert_testa input, "", ""
end

#test_invalid_optionObject



200
201
202
203
204
# File 'lib/texta.rb', line 200

def test_invalid_option
  assert_raise(NoMethodError) {  
    "ss".texta(:x)
  }
end


285
286
287
288
289
290
# File 'lib/texta.rb', line 285

def test_link
  input = "<a href='http://google.com'>Link</a>"
  html = '<p><a href="http://google.com">Link</a></p>'
  text = "[Link](http://google.com)"
  assert_testa input, text, html
end

#test_nilObject



239
240
241
# File 'lib/texta.rb', line 239

def test_nil
  assert_testa nil, nil, nil
end

#test_plain_textObject

Tests are “<input>, ”<text>“, ”<output>“”



143
144
145
146
147
148
149
# File 'lib/texta.rb', line 143

def test_plain_text
  input = "XYZ"
  text = "XYZ"
  html = "<p>XYZ</p>"
  
  assert_testa input, text, html
end

#test_string_moduleObject



196
197
198
# File 'lib/texta.rb', line 196

def test_string_module
  assert_equal "a **chd** d\n", "a <b>chd</b> d".texta(:text)
end

#test_t1Object



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/texta.rb', line 206

def test_t1
  input = <<HTML
<p>
Read this book!
</p>
<ul>
<li>All you ever wanted to know about html!</li>
<li>and even more</li>
<li>at your fingertips</li>
</ul>
HTML

  text = <<TEXT
Read this book!

- All you ever wanted to know about html!
- and even more
- at your fingertips

TEXT

  html = <<HTML
<p>Read this book!</p>
<ul>
<li>All you ever wanted to know about html!</li>
<li>and even more</li>
<li>at your fingertips</li>
</ul>
HTML

  assert_testa input, text, html
end

#test_tableObject



243
244
245
246
247
248
249
250
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
# File 'lib/texta.rb', line 243

def test_table
  input = <<-HTML
<table><tr>
<th>Farben</th>
<td>halbtransparent, halbtransparent blau (Polycarbonat)</td>
</tr>
<tr>
<th>Material</th>
<td>Körper und Flügel aus Polycarbonat</td>
</tr>
<tr>
<th>Abmessungen</th>
<td>
  <u>Höhe</u>: 44cm<br>
  <u>Durchmesser</u>: 122cm<br>
</td>
</tr>
<tr><th>Sonstiges</th><td>Steuerung über Fernbedienung</td></tr>
</table>
HTML

  text = <<-TEXT
**Farben** halbtransparent, halbtransparent blau (Polycarbonat)
**Material** Körper und Flügel aus Polycarbonat
**Abmessungen** Höhe : 44cm 
 Durchmesser : 122cm 

**Sonstiges** Steuerung über Fernbedienung
TEXT

  html = <<-HTML
<p><strong>Farben</strong> halbtransparent, halbtransparent blau (Polycarbonat)
 <strong>Material</strong> K&ouml;rper und Fl&uuml;gel aus Polycarbonat
 <strong>Abmessungen</strong> H&ouml;he : 44cm
 Durchmesser : 122cm</p>

<p> <strong>Sonstiges</strong> Steuerung &uuml;ber Fernbedienung</p>
HTML

  assert_testa input, text, html
end