-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathtest_extract_info.rb
More file actions
executable file
·60 lines (47 loc) · 1.89 KB
/
test_extract_info.rb
File metadata and controls
executable file
·60 lines (47 loc) · 1.89 KB
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
here = File.expand_path(File.dirname(__FILE__))
require File.join(here, '..', 'test_helper')
class ExtractInfoTest < Minitest::Test
def test_title
assert "PDF Pieces" == Docsplit.extract_title('test/fixtures/encrypted.pdf')
end
def test_doc_title
assert "Remarks of President Barack Obama" == Docsplit.extract_title('test/fixtures/obama_veterans.doc')
end
def test_author
assert "Jeremy Ashkenas" == Docsplit.extract_author('test/fixtures/encrypted.pdf')
end
def test_date
assert "Thu Nov 29 14:54:46 2007" == Docsplit.extract_date('test/fixtures/obama_arts.pdf')
end
def test_length
assert 2 == Docsplit.extract_length('test/fixtures/obama_arts.pdf')
end
def test_page_size
assert "612 x 792 pts (letter)" == Docsplit.extract_page_size('test/fixtures/encrypted.pdf')
end
def test_producer
assert "Mac OS X 10.6.2 Quartz PDFContext" == Docsplit.extract_producer('test/fixtures/encrypted.pdf')
end
def test_password_protected
assert_raises(ExtractionFailed) do
Docsplit.extract_author('test/fixtures/completely_encrypted.pdf')
end
end
def test_name_escaping_while_extracting_info
assert 2 == Docsplit.extract_length('test/fixtures/PDF file with spaces \'single\' and "double quotes".pdf')
end
def test_malformed_unicode
assert Docsplit.extract_date('test/fixtures/Faktura 10.pdf')
end
def test_extract_all
metadata = Docsplit.extract_info('test/fixtures/obama_arts.pdf')
assert metadata[:author] == "mkommareddi"
assert metadata[:date] == "Thu Nov 29 14:54:46 2007"
assert metadata[:creator] == "PScript5.dll Version 5.2"
assert metadata[:page_size] == "612 x 792 pts (letter)"
assert metadata[:producer] == "Acrobat Distiller 8.1.0 (Windows)"
assert metadata[:title] == "Microsoft Word - Fact Sheet Arts 112907 FINAL.doc"
assert metadata[:length] == 2
assert metadata.length == 7
end
end