Skip to content

Commit

Permalink
Test coverage of CharacterizationService on TravisCI
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Sep 1, 2015
1 parent 94d7c7d commit d00a1a9
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions spec/services/characterization_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe CurationConcerns::CharacterizationService do
let(:generic_file) { FactoryGirl.create(:generic_file) }
let(:generic_file) { create(:generic_file) }

describe '#run' do
let(:service_instance) { double }
Expand All @@ -12,14 +12,34 @@
end
end

# TODO: Enable in travis see https://github.com/projecthydra-labs/curation_concerns/issues/40
describe 'characterize', unless: $in_travis do
describe 'characterize' do
let(:fits_xml) {
'<?xml version="1.0" encoding="UTF-8"?>
<fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" version="0.6.2">
<identification status="CONFLICT">
<identity format="OpenDocument Text" mimetype="application/vnd.oasis.opendocument.text" toolname="FITS" toolversion="0.6.2">
<tool toolname="NLNZ Metadata Extractor" toolversion="3.4GA" />
</identity>
<identity format="DOCX" mimetype="application/vnd.openxmlformats-officedocument.wordprocessingml.document" toolname="FITS" toolversion="0.6.2">
<tool toolname="Exiftool" toolversion="9.06" />
</identity>
</identification>
<fileinfo />
<filestatus />
<metadata>
<document />
</metadata>
</fits>'
}
subject { described_class.new(generic_file) }
before do
Hydra::Works::UploadFileToGenericFile.call(generic_file, File.open(fixture_file_path('charter.docx')))
end

it 'characterizes, extracts fulltext and stores the results' do
expect(subject).to receive(:extract_fulltext).and_return('The fulltext')
expect(CurationConcerns::FullTextExtractionService).to receive(:run).with(generic_file).and_return('The fulltext')
expect(Hydra::FileCharacterization).to receive(:characterize).and_return(fits_xml)

subject.characterize
expect(generic_file.mime_type).to eq 'application/vnd.oasis.opendocument.text'
expect(generic_file.filename).to eq 'charter.docx'
Expand Down

0 comments on commit d00a1a9

Please sign in to comment.