zip-container 3.0.2 → 4.0.1

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.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +1 -1
  3. data/Licence.rdoc +1 -1
  4. data/Rakefile +15 -12
  5. data/examples/create-zip-container +7 -8
  6. data/examples/zip-container-info +4 -4
  7. data/lib/zip-container/container.rb +5 -7
  8. data/lib/zip-container/dir.rb +8 -11
  9. data/lib/zip-container/entries/directory.rb +5 -5
  10. data/lib/zip-container/entries/entry.rb +19 -15
  11. data/lib/zip-container/entries/file.rb +10 -9
  12. data/lib/zip-container/entries/managed.rb +11 -11
  13. data/lib/zip-container/entries/reserved.rb +2 -2
  14. data/lib/zip-container/exceptions.rb +4 -2
  15. data/lib/zip-container/file.rb +16 -16
  16. data/lib/zip-container/util.rb +3 -3
  17. data/lib/zip-container/version.rb +4 -3
  18. data/version.yml +2 -2
  19. data/zip-container.gemspec +30 -27
  20. metadata +41 -83
  21. data/.gitignore +0 -9
  22. data/.ruby-env +0 -1
  23. data/.ruby-gemset +0 -1
  24. data/.ruby-version +0 -1
  25. data/.travis.yml +0 -19
  26. data/test/data/compressed_mimetype.container +0 -0
  27. data/test/data/dirs/dir-mimetype/mimetype/.gitkeep +0 -1
  28. data/test/data/dirs/empty/mimetype +0 -1
  29. data/test/data/dirs/managed/dir/.gitkeep +0 -0
  30. data/test/data/dirs/managed/greeting.txt +0 -1
  31. data/test/data/dirs/managed/mimetype +0 -1
  32. data/test/data/dirs/null/.gitkeep +0 -1
  33. data/test/data/empty.container +0 -0
  34. data/test/data/empty.zip +0 -0
  35. data/test/data/example.container +0 -0
  36. data/test/data/null.file +0 -0
  37. data/test/data/subclassed.container +0 -0
  38. data/test/helpers/entry_lists.rb +0 -35
  39. data/test/tc_create_dir.rb +0 -56
  40. data/test/tc_create_file.rb +0 -140
  41. data/test/tc_exceptions.rb +0 -105
  42. data/test/tc_managed_entries.rb +0 -446
  43. data/test/tc_read_dir.rb +0 -90
  44. data/test/tc_read_file.rb +0 -118
  45. data/test/tc_reserved_names.rb +0 -334
  46. data/test/tc_util.rb +0 -67
  47. data/test/ts_container.rb +0 -59
@@ -1,90 +0,0 @@
1
- # Copyright (c) 2014 The University of Manchester, UK.
2
- #
3
- # All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- #
8
- # * Redistributions of source code must retain the above copyright notice,
9
- # this list of conditions and the following disclaimer.
10
- #
11
- # * Redistributions in binary form must reproduce the above copyright notice,
12
- # this list of conditions and the following disclaimer in the documentation
13
- # and/or other materials provided with the distribution.
14
- #
15
- # * Neither the names of The University of Manchester nor the names of its
16
- # contributors may be used to endorse or promote products derived from this
17
- # software without specific prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
- # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
- # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
- # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
- # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
- # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
- # POSSIBILITY OF SUCH DAMAGE.
30
- #
31
- # Author: Robert Haines
32
-
33
- require 'test/unit'
34
- require 'tmpdir'
35
- require 'zip-container'
36
-
37
- class TestReadDir < Test::Unit::TestCase
38
-
39
- # Check that the empty directory does not verify.
40
- def test_verify_empty_directory
41
- assert_raise(ZipContainer::MalformedContainerError) do
42
- ZipContainer::Dir.verify!($dir_null)
43
- end
44
-
45
- refute(ZipContainer::Dir.verify($dir_null).empty?)
46
- refute(ZipContainer::Dir.verify?($dir_null))
47
- end
48
-
49
- # Check that the empty container directory does verify.
50
- def test_verify_empty_container
51
- assert_nothing_raised(ZipContainer::MalformedContainerError) do
52
- ZipContainer::Dir.verify!($dir_empty)
53
- end
54
-
55
- assert(ZipContainer::Dir.verify($dir_empty).empty?)
56
- assert(ZipContainer::Dir.verify?($dir_empty))
57
- end
58
-
59
- # Check that a mimetype entry that is a directory does not verify.
60
- def test_verify_mimetype_directory
61
- assert_raise(ZipContainer::MalformedContainerError) do
62
- ZipContainer::Dir.verify!($dir_dir_mimetype)
63
- end
64
-
65
- refute(ZipContainer::Dir.verify($dir_dir_mimetype).empty?)
66
- refute(ZipContainer::Dir.verify?($dir_dir_mimetype))
67
- end
68
-
69
- # Check that a mimetype which is not readable does not verify. We have to
70
- # build this fixture programmatically as there's no way to add a file
71
- # without read permissions into git.
72
- def test_verify_unreadable_mimetype
73
- Dir.mktmpdir do |dir|
74
- container = File.join(dir, "unreadable.container")
75
- Dir.mkdir(container)
76
- mime_path = File.join(container, ZipContainer::Container::MIMETYPE_FILE)
77
- File.open(mime_path, "w") { |file| file.write "MIMETYPE" }
78
- File.chmod(0000, mime_path)
79
-
80
- refute File.readable?(mime_path)
81
- assert_raise(ZipContainer::MalformedContainerError) do
82
- ZipContainer::Dir.verify!(container)
83
- end
84
-
85
- refute(ZipContainer::Dir.verify(container).empty?)
86
- refute(ZipContainer::Dir.verify?(container))
87
- end
88
- end
89
-
90
- end
@@ -1,118 +0,0 @@
1
- # Copyright (c) 2013, 2014 The University of Manchester, UK.
2
- #
3
- # All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- #
8
- # * Redistributions of source code must retain the above copyright notice,
9
- # this list of conditions and the following disclaimer.
10
- #
11
- # * Redistributions in binary form must reproduce the above copyright notice,
12
- # this list of conditions and the following disclaimer in the documentation
13
- # and/or other materials provided with the distribution.
14
- #
15
- # * Neither the names of The University of Manchester nor the names of its
16
- # contributors may be used to endorse or promote products derived from this
17
- # software without specific prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
- # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
- # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
- # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
- # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
- # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
- # POSSIBILITY OF SUCH DAMAGE.
30
- #
31
- # Author: Robert Haines
32
-
33
- require 'test/unit'
34
- require 'zip-container'
35
-
36
- class TestReadFile < Test::Unit::TestCase
37
-
38
- # Check that the null file does not verify.
39
- def test_verify_null_file
40
- assert_raise(ZipContainer::ZipError) do
41
- ZipContainer::File.verify($file_null)
42
- end
43
-
44
- assert_raise(ZipContainer::ZipError) do
45
- ZipContainer::File.verify!($file_null)
46
- end
47
-
48
- assert_raise(ZipContainer::ZipError) do
49
- ZipContainer::File.verify?($file_null)
50
- end
51
- end
52
-
53
- # Check that the empty container file does verify.
54
- def test_verify_empty_container
55
- assert_nothing_raised(ZipContainer::MalformedContainerError, ZipContainer::ZipError) do
56
- ZipContainer::File.verify!($empty)
57
- end
58
-
59
- assert(ZipContainer::File.verify($empty).empty?)
60
- assert(ZipContainer::File.verify?($empty))
61
- end
62
-
63
- # Check that the empty zip file does not verify.
64
- def test_verify_empty_zip
65
- assert_raise(ZipContainer::MalformedContainerError) do
66
- ZipContainer::File.verify!($empty_zip)
67
- end
68
-
69
- refute(ZipContainer::File.verify($empty_zip).empty?)
70
- refute(ZipContainer::File.verify?($empty_zip))
71
- end
72
-
73
- # Check that a compressed mimetype file is detected.
74
- def test_verify_compressed_mimetype
75
- assert_raise(ZipContainer::MalformedContainerError) do
76
- ZipContainer::File.verify!($compressed_mimetype)
77
- end
78
-
79
- refute(ZipContainer::File.verify($compressed_mimetype).empty?)
80
- refute(ZipContainer::File.verify?($compressed_mimetype))
81
- end
82
-
83
- # Check the raw mimetype bytes
84
- def test_raw_mimetypes
85
- empty_container = File.read($empty)
86
- assert_equal("application/epub+zip", empty_container[38..57])
87
-
88
- compressed_mimetype = File.read($compressed_mimetype)
89
- assert_not_equal("application/epub+zip", compressed_mimetype[38..57])
90
- end
91
-
92
- # Check reading files out of a container file and make sure we don't change
93
- # it.
94
- def test_read_files_from_container
95
- assert_nothing_raised(ZipContainer::MalformedContainerError, ZipContainer::ZipError) do
96
- ZipContainer::File.open($example) do |c|
97
- assert(c.on_disk?)
98
- refute(c.in_memory?)
99
-
100
- assert(c.file.exists?("greeting.txt"))
101
-
102
- greeting = c.file.read("greeting.txt")
103
- assert_equal("Hello, World!\n", greeting)
104
-
105
- assert(c.file.exists?("dir"))
106
- assert(c.file.directory?("dir"))
107
-
108
- assert(c.file.exists?("dir/code.rb"))
109
-
110
- assert_equal("This is an example Container file!", c.comment)
111
-
112
- refute(c.commit_required?)
113
- refute(c.commit)
114
- end
115
- end
116
- end
117
-
118
- end
@@ -1,334 +0,0 @@
1
- # Copyright (c) 2013 The University of Manchester, UK.
2
- #
3
- # All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- #
8
- # * Redistributions of source code must retain the above copyright notice,
9
- # this list of conditions and the following disclaimer.
10
- #
11
- # * Redistributions in binary form must reproduce the above copyright notice,
12
- # this list of conditions and the following disclaimer in the documentation
13
- # and/or other materials provided with the distribution.
14
- #
15
- # * Neither the names of The University of Manchester nor the names of its
16
- # contributors may be used to endorse or promote products derived from this
17
- # software without specific prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
- # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
- # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
- # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
- # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
- # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
- # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
- # POSSIBILITY OF SUCH DAMAGE.
30
- #
31
- # Author: Robert Haines
32
-
33
- require 'test/unit'
34
- require 'zip-container'
35
-
36
- # A class to test the overriding of reserved and managed names.
37
- class NewZipContainer < ZipContainer::File
38
-
39
- private_class_method :new
40
-
41
- def initialize(filename)
42
- super(filename)
43
- register_managed_entry(ZipContainer::ManagedDirectory.new("src"))
44
- register_managed_entry(ZipContainer::ManagedDirectory.new("test"))
45
- register_managed_entry(ZipContainer::ManagedDirectory.new("lib"))
46
- register_managed_entry(ZipContainer::ManagedFile.new("index.html"))
47
- register_managed_entry(ZipContainer::ManagedFile.new("greeting.txt"))
48
-
49
- register_reserved_name("META-INF")
50
- register_reserved_name("reserved_dir")
51
- end
52
-
53
- end
54
-
55
- class TestReservedNames < Test::Unit::TestCase
56
-
57
- # Check that the reserved names verify correctly.
58
- def test_verify_reserved_name
59
- assert(NewZipContainer.verify?($example))
60
-
61
- assert_nothing_raised(ZipContainer::MalformedContainerError) do
62
- NewZipContainer.verify!($example)
63
- end
64
- end
65
-
66
- # Check the reserved names stuff all works correctly, baring in mind that
67
- # such comparisons for ZipContainer file should be case sensitive.
68
- def test_reserved_names
69
- ZipContainer::File.open($example) do |c|
70
- assert_equal(1, c.reserved_names.length)
71
- assert_equal(["mimetype"], c.reserved_names)
72
-
73
- assert_equal(0, c.managed_files.length)
74
- assert_equal([], c.managed_file_names)
75
- assert(c.reserved_entry?("mimetype"))
76
- assert(c.reserved_entry?("mimetype/"))
77
- assert(c.reserved_entry?("MimeType"))
78
-
79
- assert_equal(0, c.managed_directories.length)
80
- assert_equal([], c.managed_directory_names)
81
- refute(c.reserved_entry?("META-INF"))
82
-
83
- assert_equal(0, c.managed_entries.length)
84
- assert_equal([], c.managed_entry_names)
85
- refute(c.managed_entry?("This_should_fail"))
86
- end
87
- end
88
-
89
- # Check that overriding the reserved names in a sub-class works correctly
90
- def test_subclass_reserved_names
91
- NewZipContainer.open($example) do |c|
92
- assert_equal(3, c.reserved_names.length)
93
- assert_equal(["mimetype", "META-INF", "reserved_dir"],
94
- c.reserved_names)
95
-
96
- assert_equal(2, c.managed_files.length)
97
- assert_equal(["index.html", "greeting.txt"], c.managed_file_names)
98
- assert(c.reserved_entry?("mimetype"))
99
- assert(c.reserved_entry?("mimetype/"))
100
- assert(c.reserved_entry?("MimeType"))
101
- assert(c.managed_entry?("index.html"))
102
- assert(c.managed_entry?("Index.HTML"))
103
- refute(c.reserved_entry?("index.html"))
104
-
105
- assert_equal(3, c.managed_directories.length)
106
- assert_equal(["src", "test", "lib"], c.managed_directory_names)
107
- assert(c.managed_entry?("src"))
108
- assert(c.managed_entry?("SRC"))
109
- assert(c.managed_entry?("test"))
110
- assert(c.managed_entry?("lib"))
111
- assert(c.managed_entry?("lIb/"))
112
- refute(c.managed_entry?("META-INF"))
113
- assert(c.reserved_entry?("META-INF"))
114
- refute(c.reserved_entry?("src"))
115
- refute(c.reserved_entry?("test"))
116
- refute(c.reserved_entry?("lib"))
117
-
118
- assert_equal(5, c.managed_entries.length)
119
- assert_equal(["index.html", "greeting.txt", "src", "test", "lib"],
120
- c.managed_entry_names)
121
-
122
- refute(c.managed_entry?("This_should_fail"))
123
- refute(c.reserved_entry?("META_INF"))
124
- refute(c.reserved_entry?("META_INF/"))
125
- refute(c.managed_entry?("index.htm"))
126
- refute(c.reserved_entry?("index.html"))
127
- end
128
- end
129
-
130
- # Check that nothing happens when trying to delete the mimetype file.
131
- def test_delete_mimetype
132
- ZipContainer::File.open($example) do |c|
133
- assert(c.file.exists?("mimetype"))
134
- assert_nil(c.remove("mimetype"))
135
- assert(c.file.exists?("mimetype"))
136
- end
137
- end
138
-
139
- # Check that nothing happens when trying to rename the mimetype file.
140
- def test_rename_mimetype
141
- ZipContainer::File.open($example) do |c|
142
- assert(c.file.exists?("mimetype"))
143
- assert_nil(c.rename("mimetype", "something-else"))
144
- assert(c.file.exists?("mimetype"))
145
- refute(c.file.exists?("something-else"))
146
- end
147
- end
148
-
149
- # Check that nothing happens when trying to replace the contents of the
150
- # mimetype file.
151
- def test_replace_mimetype
152
- ZipContainer::File.open($example) do |c|
153
- assert(c.file.exists?("mimetype"))
154
- assert_nil(c.replace("mimetype", $zip_empty))
155
- assert_equal("application/epub+zip", c.file.read("mimetype"))
156
- end
157
- end
158
-
159
- # Check that an exception is raised when trying to add file with a reserved
160
- # name.
161
- def test_add_reserved
162
- ZipContainer::File.open($empty) do |c|
163
- assert_raises(ZipContainer::ReservedNameClashError) do
164
- c.add("mimetype", $zip_empty)
165
- end
166
- end
167
- end
168
-
169
- # Check that an exception is raised when trying to add file with a reserved
170
- # name to a subclassed container.
171
- def test_subclass_add_reserved
172
- NewZipContainer.open($empty) do |c|
173
- assert_raises(ZipContainer::ReservedNameClashError) do
174
- c.add("mimetype", $zip_empty)
175
- end
176
-
177
- assert_raises(ZipContainer::ReservedNameClashError) do
178
- c.add("reserved_dir", $zip_empty)
179
- end
180
-
181
- assert_raises(ZipContainer::ReservedNameClashError) do
182
- c.add("MimeType", $zip_empty)
183
- end
184
-
185
- assert_raises(ZipContainer::ReservedNameClashError) do
186
- c.add("Reserved_Dir", $zip_empty)
187
- end
188
- end
189
- end
190
-
191
- # Check that the META-INF directory is detected as non-existent when trying
192
- # to delete it.
193
- def test_delete_metainf
194
- ZipContainer::File.open($example) do |c|
195
- assert_raises(Errno::ENOENT) do
196
- c.remove("META-INF")
197
- end
198
- end
199
- end
200
-
201
- # Check that the META-INF directory is detected as non-existent when trying
202
- # to rename it.
203
- def test_rename_metainf
204
- ZipContainer::File.open($example) do |c|
205
- assert_raises(Errno::ENOENT) do
206
- c.rename("META-INF", "something-else")
207
- end
208
- end
209
- end
210
-
211
- # Check that an exception is raised when trying to create a directory with a
212
- # reserved name.
213
- def test_mkdir_reserved
214
- ZipContainer::File.open($empty) do |c|
215
- assert_raises(ZipContainer::ReservedNameClashError) do
216
- c.mkdir("mimetype")
217
- end
218
- end
219
- end
220
-
221
- # Check that an exception is raised when trying to create a directory with a
222
- # reserved name in a subclassed container.
223
- def test_subclass_mkdir_reserved
224
- NewZipContainer.open($empty) do |c|
225
- assert_raises(ZipContainer::ReservedNameClashError) do
226
- c.mkdir("mimetype")
227
- end
228
-
229
- assert_raises(ZipContainer::ReservedNameClashError) do
230
- c.mkdir("index.html")
231
- end
232
-
233
- assert_raises(ZipContainer::ReservedNameClashError) do
234
- c.mkdir("reserved_dir")
235
- end
236
-
237
- assert_raises(ZipContainer::ReservedNameClashError) do
238
- c.mkdir("Reserved_Dir")
239
- end
240
-
241
- assert_raises(ZipContainer::ReservedNameClashError) do
242
- c.mkdir("META-INF")
243
- end
244
- end
245
- end
246
-
247
- # Check that a file cannot be renamed to one of the reserved names.
248
- def test_rename_to_reserved
249
- ZipContainer::File.open($example) do |c|
250
- assert_raises(ZipContainer::ReservedNameClashError) do
251
- c.rename("dir/code.rb", "mimetype")
252
- end
253
- end
254
- end
255
-
256
- # Check that a file cannot be renamed to one of the reserved names in a
257
- # subclassed container.
258
- def test_subclass_rename_to_reserved
259
- NewZipContainer.open($example) do |c|
260
- assert_raises(ZipContainer::ReservedNameClashError) do
261
- c.rename("dir/code.rb", "mimetype")
262
- end
263
-
264
- assert_raises(ZipContainer::ReservedNameClashError) do
265
- c.rename("dir", "reserved_dir")
266
- end
267
- end
268
- end
269
-
270
- # Check that the ruby-like File and Dir classes respect reserved and managed
271
- # names.
272
- def test_file_dir_ops_reserved
273
- ZipContainer::File.open($empty) do |c|
274
- assert_raises(ZipContainer::ReservedNameClashError) do
275
- c.file.open("mimetype", "w") do |f|
276
- f.puts "TESTING"
277
- end
278
- end
279
-
280
- assert_nothing_raised(ZipContainer::ReservedNameClashError) do
281
- c.file.open("mimetype") do |f|
282
- assert_equal("application/epub+zip", f.read)
283
- end
284
- end
285
-
286
- assert_nothing_raised(ZipContainer::ReservedNameClashError) do
287
- c.file.delete("mimetype")
288
- assert(c.file.exists?("mimetype"))
289
- end
290
- end
291
- end
292
-
293
- # Check that the ruby-like File and Dir classes respect reserved names in a
294
- # subclassed container.
295
- def test_subclass_file_dir_ops_reserved
296
- NewZipContainer.open($empty) do |c|
297
- assert_raises(ZipContainer::ReservedNameClashError) do
298
- c.file.open("META-INF", "w") do |f|
299
- f.puts "TESTING"
300
- end
301
- end
302
-
303
- assert_raises(ZipContainer::ReservedNameClashError) do
304
- c.file.open("TEST", "w") do |f|
305
- f.puts "TESTING"
306
- end
307
- end
308
-
309
- assert_nothing_raised(ZipContainer::ReservedNameClashError) do
310
- c.file.open("mimetype") do |f|
311
- assert_equal("application/epub+zip", f.read)
312
- end
313
- end
314
-
315
- assert_nothing_raised(ZipContainer::ReservedNameClashError) do
316
- c.file.delete("mimetype")
317
- assert(c.file.exists?("mimetype"))
318
- end
319
-
320
- assert_raises(ZipContainer::ReservedNameClashError) do
321
- c.dir.mkdir("index.html")
322
- end
323
-
324
- assert_raises(ZipContainer::ReservedNameClashError) do
325
- c.dir.mkdir("reserved_dir")
326
- end
327
-
328
- assert_raises(ZipContainer::ReservedNameClashError) do
329
- c.dir.mkdir("Reserved_Dir")
330
- end
331
- end
332
- end
333
-
334
- end