-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
builder_spec.rb
562 lines (513 loc) · 23.2 KB
/
builder_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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
195
196
197
198
199
200
201
202
203
204
205
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
238
239
240
241
242
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/spec_helper.rb'
require 'rubygems'
describe GEPUB::Builder do
context 'metadata generating' do
it 'should generate language' do
builder = GEPUB::Builder.new {
language 'ja'
}
builder.instance_eval { @book.language }.to_s.should == 'ja'
end
it 'should generate uid' do
builder = GEPUB::Builder.new {
unique_identifier 'http://example.jp/as_url', 'BookID', 'url'
}
builder.instance_eval { @book.identifier }.to_s.should == 'http://example.jp/as_url'
builder.instance_eval { @book.identifier_list[0]['id']}.should == 'BookID'
builder.instance_eval { @book.identifier_list[0].identifier_type}.to_s.should == 'url'
end
it 'should generate title' do
builder = GEPUB::Builder.new {
title 'The Book Title'
}
builder.instance_eval { @book.title }.to_s.should == 'The Book Title'
builder.instance_eval { @book.title.title_type }.to_s.should == 'main'
end
it 'should generate title with type ' do
builder = GEPUB::Builder.new {
subtitle 'the sub-title'
}
builder.instance_eval { @book.title }.to_s.should == 'the sub-title'
builder.instance_eval { @book.title.title_type }.to_s.should == 'subtitle'
end
it 'should generate collection title ' do
builder = GEPUB::Builder.new {
collection 'the collection', 3
}
builder.instance_eval { @book.title }.to_s.should == 'the collection'
builder.instance_eval { @book.title.title_type }.to_s.should == 'collection'
builder.instance_eval { @book.title.group_position }.to_s.should == '3'
end
it 'should refine title: alternates ' do
builder = GEPUB::Builder.new {
collection 'the collection', 3
alt 'ja' => 'シリーズ'
}
builder.instance_eval { @book.title }.to_s.should == 'the collection'
builder.instance_eval { @book.title.title_type }.to_s.should == 'collection'
builder.instance_eval { @book.title.list_alternates['ja'] }.to_s.should == 'シリーズ'
end
it 'should refine title: file_as ' do
builder = GEPUB::Builder.new {
title 'メインタイトル'
file_as 'main title'
}
builder.instance_eval { @book.title }.to_s.should == 'メインタイトル'
builder.instance_eval { @book.title.title_type }.to_s.should == 'main'
builder.instance_eval { @book.title.file_as }.to_s.should == 'main title'
end
it 'should refine title: alt and file_as ' do
builder = GEPUB::Builder.new {
title 'メインタイトル'
file_as 'main title'
alt 'en' => 'The Main Title'
}
builder.instance_eval { @book.title }.to_s.should == 'メインタイトル'
builder.instance_eval { @book.title.title_type }.to_s.should == 'main'
builder.instance_eval { @book.title.file_as }.to_s.should == 'main title'
builder.instance_eval { @book.title.list_alternates['en'] }.to_s.should == 'The Main Title'
end
it 'should generate creator ' do
builder = GEPUB::Builder.new {
creator 'The Main Author'
}
builder.instance_eval { @book.creator }.to_s.should == 'The Main Author'
end
it 'should generate creator with role' do
builder = GEPUB::Builder.new {
creator 'The Illustrator', 'ill'
}
builder.instance_eval { @book.creator }.to_s.should == 'The Illustrator'
builder.instance_eval { @book.creator.role}.to_s.should == 'ill'
end
it 'should generate contributor ' do
builder = GEPUB::Builder.new {
contributor 'contributor', 'edt'
}
builder.instance_eval { @book.contributor }.to_s.should == 'contributor'
builder.instance_eval { @book.contributor.role}.to_s.should == 'edt'
end
it 'should generate multiple creators ' do
builder = GEPUB::Builder.new {
creators 'First Author', 'Second Author', ['Third Person', 'edt']
}
builder.instance_eval { @book.creator_list }.size.should == 3
builder.instance_eval { @book.creator_list[0] }.to_s.should == 'First Author'
builder.instance_eval { @book.creator_list[1] }.to_s.should == 'Second Author'
builder.instance_eval { @book.creator_list[2] }.to_s.should == 'Third Person'
builder.instance_eval { @book.creator_list[2].role }.to_s.should == 'edt'
end
it 'should generate multiple creators, and then add file_as at once ' do
builder = GEPUB::Builder.new {
creators 'First Author', 'Second Author', ['Third Person', 'edt']
file_as '1st', '2nd', '3rd'
}
builder.instance_eval { @book.creator_list }.size.should == 3
builder.instance_eval { @book.creator_list[0] }.to_s.should == 'First Author'
builder.instance_eval { @book.creator_list[0].file_as }.to_s.should == '1st'
builder.instance_eval { @book.creator_list[1] }.to_s.should == 'Second Author'
builder.instance_eval { @book.creator_list[1].file_as }.to_s.should == '2nd'
builder.instance_eval { @book.creator_list[2] }.to_s.should == 'Third Person'
builder.instance_eval { @book.creator_list[2].file_as }.to_s.should == '3rd'
builder.instance_eval { @book.creator_list[2].role }.to_s.should == 'edt'
end
it 'should generate multiple creators, and multiple alternates ' do
builder = GEPUB::Builder.new {
creators 'First Author', 'Second Author', ['Third Person', 'edt']
alts(
'ja' => ['最初','二番目', '三番目'],
'en' => ['first','second','third']
)
}
builder.instance_eval { @book.creator_list }.size.should == 3
builder.instance_eval { @book.creator_list[0] }.to_s.should == 'First Author'
builder.instance_eval { @book.creator_list[0].list_alternates['ja'] }.to_s.should == '最初'
builder.instance_eval { @book.creator_list[0].list_alternates['en'] }.to_s.should == 'first'
builder.instance_eval { @book.creator_list[1] }.to_s.should == 'Second Author'
builder.instance_eval { @book.creator_list[1].list_alternates['ja'] }.to_s.should == '二番目'
builder.instance_eval { @book.creator_list[1].list_alternates['en'] }.to_s.should == 'second'
builder.instance_eval { @book.creator_list[2] }.to_s.should == 'Third Person'
builder.instance_eval { @book.creator_list[2].list_alternates['ja'] }.to_s.should == '三番目'
builder.instance_eval { @book.creator_list[2].list_alternates['en'] }.to_s.should == 'third'
builder.instance_eval { @book.creator_list[2].role }.to_s.should == 'edt'
end
end
context 'resources' do
it 'should add a file to book' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
file('text/memo.txt')
}
}
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.should == 'just a plain text.'
end
it 'should add files to book' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
files('text/memo.txt','text/cover.xhtml')
}
}
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.should == 'just a plain text.'
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.should_not be_nil
end
it 'should add files to book with glob' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
glob 'text/*.{txt,xhtml}'
}
}
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.should == 'just a plain text.'
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.should_not be_nil
end
it 'should add files to book with import with prefix' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
import 'text/localresource.conf'
}
}
builder.instance_eval{ @book.item_by_href('memo.txt') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('memo.txt').content.chomp }.should == 'just a plain text.'
builder.instance_eval{ @book.item_by_href('cover.xhtml') }.should_not be_nil
end
it 'should add files to book with import with prefix' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
import 'text/localresource.conf', :dir_prefix => 'text'
}
}
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.should == 'just a plain text.'
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.should_not be_nil
end
it 'should add files to book from IO object' do
io = File.new(File.join(File.dirname(__FILE__),'fixtures', 'builder', 'text', 'memo.txt'))
builder = GEPUB::Builder.new {
resources() {
file('text/memo.txt' => io)
}
}
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('text/memo.txt').content.chomp }.should == 'just a plain text.'
end
it 'should add image file as cover' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
cover_image 'img/cover.jpg'
}
}
builder.instance_eval{ @book.item_by_href('img/cover.jpg') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('img/cover.jpg').properties.member? 'cover-image' }.should == true
end
it 'should add file as nav' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
nav 'text/nav.xhtml'
}
}
builder.instance_eval{ @book.item_by_href('text/nav.xhtml') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('text/nav.xhtml').properties.member? 'nav' }.should == true
end
it 'should specify mediatype' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
file('resources/noise.m4')
media_type('audio/mp4')
}
}
builder.instance_eval{ @book.item_by_href('resources/noise.m4') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }.should == 'audio/mp4'
end
it 'should specify mediatype to files' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
files('resources/noise.m4', 'resources/noise_2.m4a')
media_type('audio/mp4')
}
}
builder.instance_eval{ @book.item_by_href('resources/noise.m4') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }.should == 'audio/mp4'
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a').media_type }.should == 'audio/mp4'
end
it 'should specify mediatype to files using with_media_type' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
with_media_type('audio/mp4') {
file('resources/noise.m4')
file('resources/noise_2.m4a')
}
file('text/cover.xhtml')
}
}
builder.instance_eval{ @book.item_by_href('resources/noise.m4') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('resources/noise.m4').media_type }.should == 'audio/mp4'
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('resources/noise_2.m4a').media_type }.should == 'audio/mp4'
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.should_not be_nil
builder.instance_eval{ @book.item_by_href('text/cover.xhtml').media_type }.should == 'application/xhtml+xml'
end
it 'should specify bindings handler' do
builder = GEPUB::Builder.new {
resources {
file 'scripts/handler.xhtml' => nil
handles 'application/x-some-foregin-type'
}
}
builder.instance_eval{
@book.get_handler_of('application/x-some-foregin-type').id == @book.item_by_href('scripts/handler.xhtml').id
}
end
it 'should add files to book in spine' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
ordered {
file('text/cover.xhtml')
file('text/memo.txt')
}
}
}
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.should_not be_nil
builder.instance_eval{ @book.spine_items[0].href }.should == 'text/cover.xhtml'
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.spine_items[1].href }.should == 'text/memo.txt'
end
it 'should add files and heading' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
ordered {
file('text/cover.xhtml')
heading 'cover page'
file('text/memo.txt')
heading 'memo text'
}
}
}
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.should_not be_nil
builder.instance_eval{ @book.spine_items[0].href }.should == 'text/cover.xhtml'
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.spine_items[1].href }.should == 'text/memo.txt'
builder.instance_eval{ @book.instance_eval { @toc[0][:item].href }}.should == 'text/cover.xhtml'
builder.instance_eval{ @book.instance_eval { @toc[0][:text] }}.should == 'cover page'
builder.instance_eval{ @book.instance_eval { @toc[1][:item].href }}.should == 'text/memo.txt'
builder.instance_eval{ @book.instance_eval { @toc[1][:text] }}.should == 'memo text'
end
it 'should add files and page-spread-property' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
ordered {
file('text/cover.xhtml')
page_spread_left
file('text/memo.txt')
page_spread_right
}
}
}
builder.instance_eval{ @book.item_by_href('text/cover.xhtml') }.should_not be_nil
builder.instance_eval{ @book.spine.itemref_list[0].properties[0] }.should == 'page-spread-left'
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.spine.itemref_list[1].properties[0] }.should == 'page-spread-right'
end
it 'should add files and rendition property' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
ordered {
file('text/cover.xhtml')
file('text/memo.txt')
rendition_layout 'pre-paginated'
rendition_orientation 'landscape'
rendition_spread 'both'
}
}
}
builder.instance_eval{ @book.item_by_href('text/memo.txt') }.should_not be_nil
builder.instance_eval{ @book.spine.itemref_list[1].properties[0] }.should == 'rendition:layout-pre-paginated'
builder.instance_eval{ @book.spine.itemref_list[1].properties[1] }.should == 'rendition:orientation-landscape'
builder.instance_eval{ @book.spine.itemref_list[1].properties[2] }.should == 'rendition:spread-both'
end
it 'should handle fallback chain' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
fallback_group {
file 'chap3_docbook.xml' => nil
media_type('application/docbook+xml')
file 'chap3.xml' => nil
media_type("application/z3986-auth+xml")
file 'chap3.xhtml' => nil
}
}
}
builder.instance_eval {
fallbackid = @book.item_by_href('chap3_docbook.xml').fallback
@book.items[fallbackid].href.should == 'chap3.xml'
fallbackid = @book.items[fallbackid].fallback
@book.items[fallbackid].href.should == 'chap3.xhtml'
}
end
it 'should handle fallback chain with fallback_chain_files' do
# in this test, do not supply
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
fallback_chain_files({'chap3_docbook.xml' => nil}, {'chap3.xml' => nil}, {'chap3.xhtml' => nil})
}
}
builder.instance_eval {
fallbackid = @book.item_by_href('chap3_docbook.xml').fallback
@book.items[fallbackid].href.should == 'chap3.xml'
fallbackid = @book.items[fallbackid].fallback
@book.items[fallbackid].href.should == 'chap3.xhtml'
}
end
it 'should handle fallback chain with fallback_chain_files in with_media_type' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
resources(:workdir => workdir) {
with_media_type('application/docbook+xml', 'application/z3986-auth+xml', 'application/xhtml+xml') {
fallback_chain_files({'chap3_docbook.xml' => nil}, {'chap3.xml' => nil}, {'chap3.xhtml' => nil})
}
}
}
builder.instance_eval {
@book.item_by_href('chap3_docbook.xml').media_type.should == 'application/docbook+xml'
fallbackid = @book.item_by_href('chap3_docbook.xml').fallback
@book.items[fallbackid].href.should == 'chap3.xml'
@book.items[fallbackid].media_type.should == 'application/z3986-auth+xml'
fallbackid = @book.items[fallbackid].fallback
@book.items[fallbackid].href.should == 'chap3.xhtml'
@book.items[fallbackid].media_type.should == 'application/xhtml+xml'
}
end
it 'should handle fallback chain in spine' do
workdir = File.join(File.dirname(__FILE__),'fixtures', 'builder')
builder = GEPUB::Builder.new {
unique_identifier 'uid'
resources(:workdir => workdir) {
ordered {
fallback_group {
file 'chap3_docbook.xml' => nil
media_type('application/docbook+xml')
file 'chap3.xml' => nil
media_type("application/z3986-auth+xml")
file 'chap3.xhtml' => nil
}
}
}
}
builder.instance_eval {
@book.cleanup
fallbackid = @book.item_by_href('chap3_docbook.xml').fallback
@book.items[fallbackid].href.should == 'chap3.xml'
fallbackid = @book.items[fallbackid].fallback
@book.items[fallbackid].href.should == 'chap3.xhtml'
@book.spine_items.size.should == 1
@book.spine_items[0].href == 'chap3_docbook.xhtml'
}
end
it 'should create remote-resources' do
builder = GEPUB::Builder.new {
unique_identifier 'uid'
resources {
file 'with_remote.xhtml' => StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><head></head><body><div><p><video src="http://foo.bar">no video</video></p></div></body></html>')
}
}
builder.instance_eval {
@book.item_by_href('with_remote.xhtml').properties[0].should == 'remote-resources'
}
end
it 'should handle remote resource URL' do
builder = GEPUB::Builder.new {
unique_identifier 'uid'
resources {
file 'http://foo.bar'
}
}
# this should not raise 'No such file or directory'
end
it 'should handle mathml' do
builder = GEPUB::Builder.new {
unique_identifier 'uid'
resources {
file 'mathml.xhtml' => StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><head></head><body><div><p><math xmlns="http://www.w3.org/1998/Math/MathML"></math></p></div></body></html>')
}
}
builder.instance_eval {
@book.item_by_href('mathml.xhtml').properties[0].should == 'mathml'
}
end
it 'should handle svg' do
builder = GEPUB::Builder.new {
unique_identifier 'uid'
resources {
file 'svg.xhtml' => StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><head></head><body><div><p><svg xmlns="http://www.w3.org/2000/svg"></svg></p></div></body></html>')
}
}
builder.instance_eval {
@book.item_by_href('svg.xhtml').properties[0].should == 'svg'
}
end
it 'should handle epub:switch' do
builder = GEPUB::Builder.new {
unique_identifier 'uid'
resources {
file 'switch.xhtml' => StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><head></head><body><div><p>
<epub:switch>
<epub:case required-namespace="http://www.xml-cml.org/schema">
<cml xmlns="http://www.xml-cml.org/schema">
<molecule id="sulfuric-acid">
<formula id="f1" concise="H 2 S 1 O 4"/>
</molecule>
</cml>
</epub:case>
<epub:default>
<p>H<sub>2</sub>SO<sub>4</sub></p>
</epub:default>
</epub:switch></p></div></body></html>')
}
}
builder.instance_eval {
@book.item_by_href('switch.xhtml').properties[0].should == 'switch'
}
end
it 'should handle scripted property' do
builder = GEPUB::Builder.new {
unique_identifier 'uid'
resources {
file 'scripted.xhtml' => StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><head><script>alert("scripted");</script></head><body><div><p>text comes here</p></div></body></html>')
}
}
builder.instance_eval {
@book.item_by_href('scripted.xhtml').properties[0].should == 'scripted'
}
end
it 'should handle optional file' do
builder = GEPUB::Builder.new {
optional_file 'META-INF/test.xml' => StringIO.new('<test></test>')
}
builder.instance_eval {
@book.optional_files.size.should == 1
}
builder.instance_eval {
@book.optional_files['META-INF/test.xml']
}.should_not be_nil
end
end
end