Skip to content

Commit

Permalink
Merge pull request #284 from ifad/chore/fix-specs-ii
Browse files Browse the repository at this point in the history
Chore/fix specs ii
  • Loading branch information
tagliala authored Sep 14, 2024
2 parents 520e72f + cbb1cd7 commit 62f41c1
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 155 deletions.
34 changes: 0 additions & 34 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions spec/heathen/convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def failing_step_1
end

it 'runs a successful task' do
Heathen::Task.register 'test', 'text/plain' do |job|
Heathen::Task.register 'test', 'text/plain' do
valid_step_1
valid_step_2
end
Expand All @@ -36,7 +36,7 @@ def failing_step_1
end

it 'finds and runs based on pattern' do
Heathen::Task.register 'test', 'text/.*' do |job|
Heathen::Task.register 'test', 'text/.*' do
valid_step_1
valid_step_2
end
Expand All @@ -45,20 +45,20 @@ def failing_step_1
end

it 'fails with an unsuccessful step' do
Heathen::Task.register 'test', 'text/plain' do |job|
Heathen::Task.register 'test', 'text/plain' do
valid_step_1
failing_step_1
end
expect {
expect do
described_class.new.convert 'test', 'test content'
}.to raise_error(RuntimeError, 'It failed')
end.to raise_error(RuntimeError, 'It failed')
end

it 'runs a nested task' do
Heathen::Task.register 'test_nested', 'text/plain' do |job|
Heathen::Task.register 'test_nested', 'text/plain' do
valid_step_1
end
Heathen::Task.register 'test', 'text/plain' do |job|
Heathen::Task.register 'test', 'text/plain' do
perform_task 'test_nested'
valid_step_2
end
Expand All @@ -67,22 +67,22 @@ def failing_step_1
end

it 'fails if the task is not recognised' do
Heathen::Task.register 'test', 'text/plain' do |job|
Heathen::Task.register 'test', 'text/plain' do
valid_step_1
valid_step_2
end
expect {
expect do
described_class.new.convert 'test_foo', 'test content'
}.to raise_error Heathen::TaskNotFound
end.to raise_error Heathen::TaskNotFound
end

it 'fails if the mime_type is not recognised' do
Heathen::Task.register 'test', 'image/jpeg' do |job|
Heathen::Task.register 'test', 'image/jpeg' do
valid_step_1
valid_step_2
end
expect {
expect do
described_class.new.convert 'test', 'test content'
}.to raise_error Heathen::TaskNotFound
end.to raise_error Heathen::TaskNotFound
end
end
36 changes: 18 additions & 18 deletions spec/heathen/processor_methods/libreoffice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,92 +20,92 @@ def new_job(content)
end

describe '#libreoffice' do
context 'convert to PDF' do
it 'from MS word' do
context 'when converting to PDF' do
it 'converts from MS word' do
new_job ms_word_content
@processor.libreoffice format: 'pdf'
expect(@job.content.mime_type).to eq 'application/pdf; charset=binary'
end

it 'from MS spreadsheet' do
it 'converts from MS spreadsheet' do
new_job ms_spreadsheet_content
@processor.libreoffice format: 'pdf'
expect(@job.content.mime_type).to eq 'application/pdf; charset=binary'
end

it 'from MS powerpoint' do
it 'converts from MS powerpoint' do
new_job ms_ppt_content
@processor.libreoffice format: 'pdf'
expect(@job.content.mime_type).to eq 'application/pdf; charset=binary'
end

it 'from OO word' do
it 'converts from OO word' do
new_job oo_word_content
@processor.libreoffice format: 'pdf'
expect(@job.content.mime_type).to eq 'application/pdf; charset=binary'
end

it 'from OO spreadsheet' do
it 'converts from OO spreadsheet' do
new_job oo_spreadsheet_content
@processor.libreoffice format: 'pdf'
expect(@job.content.mime_type).to eq 'application/pdf; charset=binary'
end

it 'from OO presentation' do
it 'converts from OO presentation' do
new_job oo_presentation_content
@processor.libreoffice format: 'pdf'
expect(@job.content.mime_type).to eq 'application/pdf; charset=binary'
end
end

context 'convert to MS' do
it 'from OO word' do
context 'when converting to MS' do
it 'converts from OO word' do
new_job oo_word_content
@processor.libreoffice format: 'msoffice'
expect(ms_word_mime_types).to include(@job.content.mime_type)
end

it 'from OO spreadsheet' do
it 'converts from OO spreadsheet' do
new_job oo_spreadsheet_content
@processor.libreoffice format: 'msoffice'
expect(ms_excel_mime_types).to include(@job.content.mime_type)
end

it 'from OO presentation' do
it 'converts from OO presentation' do
new_job oo_presentation_content
@processor.libreoffice format: 'msoffice'
expect(ms_powerpoint_mime_types).to include(@job.content.mime_type)
end
end

context 'convert to OO' do
it 'from MS word' do
context 'when converting to OO' do
it 'converts from MS word' do
new_job ms_word_content
@processor.libreoffice format: 'ooffice'
expect(oo_odt_mime_types).to include(@job.content.mime_type)
end

it 'from MS spreadsheet' do
it 'converts from MS spreadsheet' do
new_job ms_spreadsheet_content
@processor.libreoffice format: 'ooffice'
expect(oo_ods_mime_types).to include(@job.content.mime_type)
end

it 'from MS powerpoint' do
it 'converts from MS powerpoint' do
new_job ms_ppt_content
@processor.libreoffice format: 'ooffice'
expect(oo_odp_mime_types).to include(@job.content.mime_type)
end
end

context 'convert to TXT' do
it 'from MS word' do
context 'when converting to TXT' do
it 'converts from MS word' do
new_job ms_word_content
@processor.libreoffice format: 'txt'
expect(@job.content.mime_type).to eq 'text/plain; charset=us-ascii'
end

it 'from OO word' do
it 'converts from OO word' do
new_job oo_word_content
@processor.libreoffice format: 'txt'
expect(@job.content.mime_type).to eq 'text/plain; charset=us-ascii'
Expand Down
14 changes: 7 additions & 7 deletions spec/integration/standard_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

let(:converter) { Heathen::Converter.new(logger: spec_logger) }

context 'ocr' do
describe '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
describe 'ocr_text' do
it 'converts jpeg' do
content = fixture('heathen/quickfox.jpg').read
new_content = converter.convert 'ocr_text', content
Expand All @@ -36,7 +36,7 @@
end
end

context 'pdf' do
describe 'pdf' do
it 'converts images' do
content = fixture('heathen/quickfox.jpg').read
new_content = converter.convert 'pdf', content
Expand All @@ -56,7 +56,7 @@
end
end

context 'txt' do
describe 'txt' do
it 'converts odt' do
content = fixture('heathen/ooword.odt').read
new_content = converter.convert 'txt', content
Expand Down Expand Up @@ -88,23 +88,23 @@
end
end

context 'msoffice' do
describe '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
describe 'ooffice' do
it 'runs' do
content = fixture('heathen/msword.docx').read
new_content = converter.convert 'ooffice', content
expect(oo_odt_mime_types).to include(new_content.mime_type)
end
end

context 'doc' do
describe 'doc' do
it 'runs' do
content = fixture('heathen/ooword.odt').read
new_content = converter.convert 'doc', content
Expand Down
Loading

0 comments on commit 62f41c1

Please sign in to comment.