tdiary 4.0.1.20130903 → 4.0.1.20130929

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,512 +0,0 @@
1
- # -*- coding: utf-8; -*-
2
- require 'spec_helper'
3
-
4
- require 'tdiary'
5
- require 'misc/style/etdiary/etdiary_style'
6
-
7
- describe TDiary::Style::EtdiaryDiary do
8
- before do
9
- @diary = TDiary::Style::EtdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
10
- end
11
-
12
- describe '#append' do
13
- before do
14
- @source = <<-'EOF'
15
- hogehoge
16
- fugafuga
17
-
18
- fugahoge
19
- hogera
20
-
21
- <<subTitle>>
22
- honbun
23
-
24
- <<<>subTitleH4>>
25
- honbun
26
-
27
- <h4>notParagraph</h4>
28
-
29
- <div>
30
- Content of block element with blank line.
31
-
32
- <blockquote>
33
- hogehoge
34
- </blockquote>
35
- </div>
36
-
37
- <b>Paragraph</b> begin with tag.
38
-
39
- <pre>
40
- In <pre>, < and > are automatically escaped.
41
- </pre>
42
-
43
- <<>>
44
- Section without title and anchor.
45
-
46
- <<<>>>
47
- Section without title.
48
- EOF
49
- @diary.append(@source)
50
- end
51
-
52
- context 'HTML' do
53
- before do
54
- @html = <<-'EOF'
55
- <div class="section">
56
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
57
- <p>
58
- hogehoge
59
- fugafuga
60
- </p>
61
- <p>
62
- fugahoge
63
- hogera
64
- </p>
65
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
66
- </div>
67
-
68
- <div class="section">
69
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
70
- <h3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle" ) %></h3>
71
- <p>
72
- honbun
73
- </p>
74
- <h4><%= subtitle_proc( Time::at( 1041346800 ), "subTitleH4" ) %>:</h4>
75
- <p>
76
- honbun
77
- </p>
78
- <h4>notParagraph</h4>
79
- <div>
80
- Content of block element with blank line.
81
-
82
- <blockquote>
83
- hogehoge
84
- </blockquote>
85
- </div>
86
- <p>
87
- <b>Paragraph</b> begin with tag.
88
- </p>
89
- <pre>
90
- In &lt;pre&gt;, &lt; and &gt; are automatically escaped.
91
- </pre>
92
- <p><%= subtitle_proc( Time::at( 1041346800 ), nil ) %>
93
- Section without title and anchor.
94
- </p>
95
- <p><a name="p04"></a>
96
- Section without title.
97
- </p>
98
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
99
- </div>
100
- EOF
101
- end
102
- it { @diary.to_html.should eq @html }
103
- end
104
-
105
- context 'CHTML' do
106
- before do
107
- @html = <<-'EOF'
108
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
109
- <P>
110
- hogehoge
111
- fugafuga
112
- </P>
113
- <P>
114
- fugahoge
115
- hogera
116
- </P>
117
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
118
-
119
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
120
- <H3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle" ) %></H3>
121
- <P>
122
- honbun
123
- </P>
124
- <P><%= subtitle_proc( Time::at( 1041346800 ), "subTitleH4" ) %>:
125
- honbun
126
- </P>
127
- <h4>notParagraph</h4>
128
- <div>
129
- Content of block element with blank line.
130
-
131
- <blockquote>
132
- hogehoge
133
- </blockquote>
134
- </div>
135
- <P>
136
- <b>Paragraph</b> begin with tag.
137
- </P>
138
- <PRE>
139
- In &lt;pre&gt;, &lt; and &gt; are automatically escaped.
140
- </PRE>
141
- <P><%= subtitle_proc( Time::at( 1041346800 ), nil ) %>
142
- Section without title and anchor.
143
- </P>
144
- <P><A NAME="p04"></A>
145
- Section without title.
146
- </P>
147
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
148
- EOF
149
- end
150
- it { @diary.to_html({'anchor' => true, 'index' => true}, :CHTML).should eq @html }
151
- end
152
-
153
- context 'to_src' do
154
- it { @diary.to_src.should eq @source }
155
- end
156
- end
157
-
158
- describe '#add_section' do
159
- before do
160
- source = <<-'EOF'
161
- <<subTitle>>
162
- honbun
163
-
164
- <<<>subTitleH4>>
165
- honbun
166
-
167
- EOF
168
- @diary.append(source)
169
- @diary.add_section('subTitle2', 'honbun')
170
-
171
- @html = <<-'EOF'
172
- <div class="section">
173
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
174
- <h3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle" ) %></h3>
175
- <p>
176
- honbun
177
- </p>
178
- <h4><%= subtitle_proc( Time::at( 1041346800 ), "subTitleH4" ) %>:</h4>
179
- <p>
180
- honbun
181
- </p>
182
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
183
- </div>
184
-
185
- <div class="section">
186
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
187
- <h3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle2" ) %></h3>
188
- <p>
189
- honbun
190
- </p>
191
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
192
- </div>
193
- EOF
194
- end
195
- it { @diary.to_html.should eq @html }
196
- end
197
-
198
- describe '#delete_section' do
199
- before do
200
- source = <<-'EOF'
201
- <<subTitle>>
202
- honbun
203
-
204
- <<subTitle2>>
205
- honbun
206
-
207
- EOF
208
- @diary.append(source)
209
- @diary.delete_section(1)
210
-
211
- @html = <<-'EOF'
212
- <div class="section">
213
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
214
- <h3><%= subtitle_proc( Time::at( 1041346800 ), "subTitle2" ) %></h3>
215
- <p>
216
- honbun
217
- </p>
218
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
219
- </div>
220
- EOF
221
- end
222
- it { @diary.to_html.should eq @html }
223
- end
224
-
225
- describe '#replace' do
226
- before do
227
- source = <<-'EOF'
228
- <<subTitle>>
229
- honbun
230
-
231
- <<<>subTitleH4>>
232
- honbun
233
-
234
- EOF
235
- @diary.append(source)
236
-
237
- replaced = <<-'EOF'
238
- <<replaceTitle>>
239
- replace
240
-
241
- <<<>replaceTitleH4>>
242
- replace
243
-
244
- EOF
245
- @diary.replace(Time::at( 1041346800 ), "TITLE", replaced)
246
-
247
- @html = <<-'EOF'
248
- <div class="section">
249
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
250
- <h3><%= subtitle_proc( Time::at( 1041346800 ), "replaceTitle" ) %></h3>
251
- <p>
252
- replace
253
- </p>
254
- <h4><%= subtitle_proc( Time::at( 1041346800 ), "replaceTitleH4" ) %>:</h4>
255
- <p>
256
- replace
257
- </p>
258
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
259
- </div>
260
- EOF
261
- end
262
- it { @diary.to_html.should eq @html }
263
- end
264
-
265
- describe 'test_etdiary_unterminated_tag' do
266
- before do
267
- source = <<-'EOF'
268
- <p>
269
- paragraph
270
- </q>
271
- EOF
272
- @diary.append(source)
273
- end
274
-
275
- context 'HTML' do
276
- before do
277
- @html = <<-'EOF'
278
- <div class="section">
279
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
280
- <p>
281
- paragraph
282
- </q>
283
-
284
- </p>(tDiary warning: tag &lt;p&gt; is not terminated.)
285
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
286
- </div>
287
- EOF
288
- end
289
- it { @diary.to_html.should eq @html }
290
- end
291
-
292
- context 'CHTML' do
293
- before do
294
- @html = <<-'EOF'
295
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
296
- <p>
297
- paragraph
298
- </q>
299
-
300
- </p>(tDiary warning: tag &lt;p&gt; is not terminated.)
301
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
302
- EOF
303
- end
304
- it { @diary.to_html({'anchor' => true, 'index' => true}, :CHTML).should eq @html }
305
- end
306
- end
307
-
308
- describe 'test_etdiary_null' do
309
- before do
310
- source = <<-'EOF'
311
- EOF
312
- @diary.append(source)
313
- end
314
-
315
- context 'HTML' do
316
- before do
317
- @html = <<-'EOF'
318
- <div class="section">
319
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
320
- <p>
321
- </p>
322
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
323
- </div>
324
- EOF
325
- end
326
- it { @diary.to_html.should eq @html }
327
- end
328
-
329
- context 'CHTML' do
330
- before do
331
- @html = <<-'EOF'
332
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
333
- <P>
334
- </P>
335
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
336
- EOF
337
- end
338
- it { @diary.to_html({'anchor' => true, 'index' => true}, :CHTML).should eq @html }
339
- end
340
- end
341
-
342
- describe 'test_etdiary_sectionAtBeginning' do
343
- before do
344
- source = <<-'EOF'
345
- <<hoge>>
346
- fuga
347
- EOF
348
- @diary.append(source)
349
- end
350
-
351
- context 'HTML' do
352
- before do
353
- @html = <<-'EOF'
354
- <div class="section">
355
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
356
- <h3><%= subtitle_proc( Time::at( 1041346800 ), "hoge" ) %></h3>
357
- <p>
358
- fuga
359
- </p>
360
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
361
- </div>
362
- EOF
363
- end
364
- it { @diary.to_html.should eq @html }
365
- end
366
-
367
- context 'CHTML' do
368
- before do
369
- @html = <<-'EOF'
370
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
371
- <H3><%= subtitle_proc( Time::at( 1041346800 ), "hoge" ) %></H3>
372
- <P>
373
- fuga
374
- </P>
375
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
376
- EOF
377
- end
378
- it { @diary.to_html({'anchor' => true, 'index' => true}, :CHTML).should eq @html }
379
- end
380
- end
381
-
382
- describe 'test_etdiary_appending' do
383
- before do
384
- source = <<-'EOF'
385
- <p>para1</p>
386
- EOF
387
-
388
- sourceAppended = <<-'EOF'
389
- <p>para2</p>
390
- EOF
391
- @diary.append(source)
392
- @diary.append(sourceAppended)
393
- end
394
-
395
- context 'HTML' do
396
- before do
397
- @html = <<-'EOF'
398
- <div class="section">
399
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
400
- <p>para1</p>
401
- <p>para2</p>
402
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
403
- </div>
404
- EOF
405
- end
406
- it { @diary.to_html.should eq @html }
407
- end
408
-
409
- context 'CHTML' do
410
- before do
411
- @html = <<-'EOF'
412
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
413
- <p>para1</p>
414
- <p>para2</p>
415
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
416
- EOF
417
- end
418
- it { @diary.to_html({'anchor' => true, 'index' => true}, :CHTML).should eq @html }
419
- end
420
- end
421
-
422
- # 2004.08.12 Reported by Shun-ichi TAHARA, thanks!
423
- describe 'test_etdiary_subsequentPREtoSectionTitle' do
424
- before do
425
- source = <<-'EOF'
426
- <<hoge>>
427
- <pre>
428
- hoge
429
-
430
- fuga
431
- </pre>
432
- EOF
433
- @diary.append(source)
434
- end
435
-
436
- context 'HTML' do
437
- before do
438
- @html = <<-'EOF'
439
- <div class="section">
440
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
441
- <h3><%= subtitle_proc( Time::at( 1041346800 ), "hoge" ) %></h3>
442
- <pre>
443
- hoge
444
-
445
- fuga
446
- </pre>
447
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
448
- </div>
449
- EOF
450
- end
451
- it { @diary.to_html.should eq @html }
452
- end
453
-
454
- context 'CHTML' do
455
- before do
456
- @html = <<-'EOF'
457
- <%=section_enter_proc( Time::at( 1041346800 ) )%>
458
- <H3><%= subtitle_proc( Time::at( 1041346800 ), "hoge" ) %></H3>
459
- <PRE>
460
- hoge
461
-
462
- fuga
463
- </PRE>
464
- <%=section_leave_proc( Time::at( 1041346800 ) )%>
465
- EOF
466
- end
467
- it { @diary.to_html({'anchor' => true, 'index' => true}, :CHTML).should eq @html }
468
- end
469
- end
470
-
471
- # 2004.08.19 Reported by Shun-ichi TAHARA, thanks!
472
- describe 'test_etdiary_badAnchorNumber' do
473
- before do
474
- source = <<-'EOF'
475
- sect0-para0
476
-
477
- <<sect1>>
478
- sect1-para0
479
-
480
- sect1-para1
481
-
482
- sect1-para2
483
-
484
- <<sect2>>
485
- sect2-para0
486
- EOF
487
-
488
- @diary.append(source)
489
- sections = []
490
- @diary.each_section { |sect|
491
- sections << sect
492
- }
493
-
494
- @anchorNumber = 0
495
- @section = sections.find do |sect|
496
- @anchorNumber += 1
497
- (sect.subtitle == "sect2")
498
- end
499
- end
500
- it { @section.should_not be_nil }
501
- it { @anchorNumber.should eq 2 }
502
- # github issue #271
503
- it { @section.body_to_html.should eq "<p>sect2-para0\n</p>\n" }
504
- end
505
- end
506
-
507
- # Local Variables:
508
- # mode: ruby
509
- # indent-tabs-mode: t
510
- # tab-width: 3
511
- # ruby-indent-level: 3
512
- # End: