-
Notifications
You must be signed in to change notification settings - Fork 3
/
standard_tasks_spec.rb
112 lines (95 loc) · 3.39 KB
/
standard_tasks_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
require 'spec_helper'
describe 'Standard Heathen tasks:' do
before do
setup_storage
allow(Colore::C_).to receive(:storage_directory) { tmp_storage_dir }
end
after do
delete_storage
end
let(:converter) { Heathen::Converter.new(logger: Logger.new($stderr)) }
context 'ocr' do
it 'runs' do
content = fixture('heathen/quickfox.jpg').read
new_content = converter.convert 'ocr', content
expect(new_content.mime_type).to eq 'application/pdf; charset=binary'
end
end
context 'ocr_text' do
it 'converts jpeg' do
content = fixture('heathen/quickfox.jpg').read
new_content = converter.convert 'ocr_text', content
expect(new_content.mime_type).to eq 'text/plain; charset=us-ascii'
end
it 'converts bmp' do
content = fixture('heathen/quickfox.bmp').read
new_content = converter.convert 'ocr_text', content
expect(new_content.mime_type).to eq 'text/plain; charset=us-ascii'
end
end
context 'pdf' do
it 'converts images' do
content = fixture('heathen/quickfox.jpg').read
new_content = converter.convert 'pdf', content
expect(new_content.mime_type).to eq 'application/pdf; charset=binary'
end
it 'converts HTML documents' do
content = fixture('heathen/quickfox.html').read
new_content = converter.convert 'pdf', content
expect(new_content.mime_type).to eq 'application/pdf; charset=binary'
end
it 'converts Office documents' do
content = fixture('heathen/msword.docx').read
new_content = converter.convert 'pdf', content
expect(new_content.mime_type).to eq 'application/pdf; charset=binary'
end
end
context 'txt' do
it 'converts odt' do
content = fixture('heathen/ooword.odt').read
new_content = converter.convert 'txt', content
expect(new_content.mime_type).to eq 'text/plain; charset=us-ascii'
end
it 'converts docx' do
content = fixture('heathen/msword.docx').read
new_content = converter.convert 'txt', content
expect(new_content.mime_type).to eq 'text/plain; charset=us-ascii'
end
it 'converts images' do
content = fixture('heathen/quickfox.jpg').read
new_content = converter.convert 'txt', content
expect(new_content.mime_type).to eq 'text/plain; charset=us-ascii'
end
it 'converts pdf' do
content = fixture('heathen/quickfox.pdf').read
new_content = converter.convert 'txt', content
expect(new_content.mime_type).to eq 'text/plain; charset=us-ascii'
end
it 'converts HTML documents' do
content = fixture('heathen/quickfox.html').read
new_content = converter.convert 'txt', content
expect(new_content.mime_type).to eq 'text/plain; charset=us-ascii'
end
end
context 'msoffice' do
it 'runs' do
content = fixture('heathen/ooword.odt').read
new_content = converter.convert 'msoffice', content
expect(ms_word_mime_types).to include(new_content.mime_type)
end
end
context 'ooffice' do
it 'runs' do
content = fixture('heathen/msword.docx').read
new_content = converter.convert 'ooffice', content
expect(oo_mime_types).to include(new_content.mime_type)
end
end
context 'doc' do
it 'runs' do
content = fixture('heathen/ooword.odt').read
new_content = converter.convert 'doc', content
expect(ms_word_mime_types).to include(new_content.mime_type)
end
end
end