|
73 | 73 | </html>
|
74 | 74 | EOF
|
75 | 75 | item3 = @book.add_ordered_item('text/nav.xhtml', content: StringIO.new(nav_string), id: 'nav').add_property('nav')
|
| 76 | + |
| 77 | + @tempdir = Dir.mktmpdir |
76 | 78 | end
|
77 | 79 |
|
| 80 | + after do |
| 81 | + FileUtils.remove_entry_secure @tempdir |
| 82 | + end |
| 83 | + |
78 | 84 | it "should have title" do
|
79 | 85 | expect(@book.title.to_s).to eq('thetitle')
|
80 | 86 | end
|
|
153 | 159 | end
|
154 | 160 |
|
155 | 161 | it "should generate correct epub" do
|
156 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub.epub') |
| 162 | + epubname = File.join(@tempdir, 'testepub.epub') |
157 | 163 | @book.generate_epub(epubname)
|
158 | 164 | epubcheck(epubname)
|
159 | 165 | end
|
160 | 166 |
|
161 | 167 | it "should generate correct epub with buffer" do
|
162 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub_buf.epub') |
| 168 | + epubname = File.join(@tempdir, 'testepub_buf.epub') |
163 | 169 | File.open(epubname, 'wb') {
|
164 | 170 | |io|
|
165 | 171 | io.write @book.generate_epub_stream.string
|
|
168 | 174 | end
|
169 | 175 |
|
170 | 176 | it "should generate correct epub2.0" do
|
171 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub2.epub') |
| 177 | + epubname = File.join(@tempdir, 'testepub2.epub') |
172 | 178 | @book = GEPUB::Book.new('OEPBS/package.opf', { 'version' => '2.0'} )
|
173 | 179 | @book.title = 'thetitle'
|
174 | 180 | @book.creator = "theauthor"
|
|
188 | 194 | epubcheck(epubname)
|
189 | 195 | end
|
190 | 196 | it 'should generate epub with extra file' do
|
191 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub3.epub') |
| 197 | + epubname = File.join(@tempdir, 'testepub3.epub') |
192 | 198 | @book.add_optional_file('META-INF/foobar.xml', StringIO.new('<foo></foo>'))
|
193 | 199 | @book.generate_epub(epubname)
|
194 | 200 | epubcheck(epubname)
|
195 | 201 | end
|
196 | 202 |
|
197 | 203 | it 'should generate valid EPUB when @toc is empty' do
|
198 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub4.epub') |
| 204 | + epubname = File.join(@tempdir, 'testepub4.epub') |
199 | 205 | @book = GEPUB::Book.new('OEPBS/package.opf', { 'version' => '3.0'} )
|
200 | 206 | @book.title = 'thetitle'
|
201 | 207 | @book.creator = "theauthor"
|
|
215 | 221 | end
|
216 | 222 |
|
217 | 223 | it 'should generate EPUB with specified lastmodified' do
|
218 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub.epub') |
| 224 | + epubname = File.join(@tempdir, 'testepub.epub') |
219 | 225 | mod_time = Time.mktime(2010,5,5,8,10,15)
|
220 | 226 | @book.lastmodified = mod_time
|
221 | 227 | @book.generate_epub(epubname)
|
|
227 | 233 |
|
228 | 234 |
|
229 | 235 | it 'should generate EPUB with specified lastmodified by string' do
|
230 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub.epub') |
| 236 | + epubname = File.join(@tempdir, 'testepub.epub') |
231 | 237 | mod_time = "2010-05-05T08:10:15Z"
|
232 | 238 | @book.lastmodified = mod_time
|
233 | 239 | @book.generate_epub(epubname)
|
|
239 | 245 |
|
240 | 246 | it 'should generate parsed and generated EPUB with renewed lastmodified' do
|
241 | 247 | originalfile = File.join(File.dirname(__FILE__), 'fixtures/testdata/wasteland-20120118.epub')
|
242 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub.epub') |
| 248 | + epubname = File.join(@tempdir, 'testepub.epub') |
243 | 249 |
|
244 | 250 | original_book = File.open(originalfile) do |f|
|
245 | 251 | GEPUB::Book.parse(f)
|
|
256 | 262 |
|
257 | 263 | it 'should generate parsed and generated EPUB with newly set lastmodified' do
|
258 | 264 | originalfile = File.join(File.dirname(__FILE__), 'fixtures/testdata/wasteland-20120118.epub')
|
259 |
| - epubname = File.join(File.dirname(__FILE__), 'testepub.epub') |
| 265 | + epubname = File.join(@tempdir, 'testepub.epub') |
260 | 266 | mod_time = Time.mktime(2010,5,5,8,10,15)
|
261 | 267 |
|
262 | 268 | original_book = File.open(originalfile) do |f|
|
|
281 | 287 | end
|
282 | 288 |
|
283 | 289 | it 'should produce deterministic output when lastmodified is specified' do
|
284 |
| - epubname1 = File.join(File.dirname(__FILE__), 'testepub1.epub') |
285 |
| - epubname2 = File.join(File.dirname(__FILE__), 'testepub2.epub') |
| 290 | + epubname1 = File.join(@tempdir, 'testepub1.epub') |
| 291 | + epubname2 = File.join(@tempdir, 'testepub2.epub') |
286 | 292 | mod_time = "2010-05-05T08:10:15Z"
|
287 | 293 | @book.lastmodified = mod_time
|
288 | 294 |
|
|
297 | 303 | @book = GEPUB::Book.new
|
298 | 304 | @book.identifier = 'test'
|
299 | 305 | @book.add_ordered_item('foobar.xhtml', content: StringIO.new('<html><img src="image.svg" /></html>')).add_property 'svg'
|
300 |
| - epubname = File.join(__dir__, 'testepub.epub') |
| 306 | + epubname = File.join(@tempdir, 'testepub.epub') |
301 | 307 | @book.generate_epub(epubname)
|
302 | 308 | File.open(epubname) do |f|
|
303 | 309 | parsed_book = GEPUB::Book.parse(f)
|
|
0 commit comments