Sha256: 86ad25cc10d0c0c1986ce52f1f81f6069d6145c49fa6558b81a31e9aa10d60f9

Contents?: true

Size: 1.96 KB

Versions: 12

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

module Ddr::Jobs
  RSpec.describe FitsFileCharacterization, jobs: true, file_characterization: true do

    shared_examples "has a fits update event" do
      let(:event) { object.update_events.last }
      it "should have the correct event attributes" do
        expect(event.outcome).to eq(expected_outcome)
        expect(event.detail).to eq(expected_detail)
        expect(event.software).to eq("fits #{fits_version}")
      end
    end

    context "content-bearing object" do
      let(:object) { TestContent.create }
      let(:stdout_msg) { '<fits />' }
      let(:stderr_msg) { 'stderr msg' }
      let(:fits_version) { '0.9.9 '}
      before { allow(Ddr::Jobs::FitsFileCharacterization).to receive(:fits_version) { fits_version } }
      context "fits command is successful" do
        let(:expected_outcome) { Ddr::Events::Event::SUCCESS }
        let(:expected_detail) { nil }
        before do
          allow(Open3).to receive(:capture3) { [ stdout_msg, stderr_msg,  $? ] }
          allow_any_instance_of(Process::Status).to receive(:success?) { true }
          Ddr::Jobs::FitsFileCharacterization.perform(object.pid)
          object.reload
        end
        it "should populate the fits datastream" do
          expect(object.fits.content).to be_present
        end
        it_behaves_like "has a fits update event"
      end
      context "fits command is not successful" do
        let(:expected_outcome) { Ddr::Events::Event::FAILURE }
        let(:expected_detail) { stderr_msg }
        before do
          allow(Open3).to receive(:capture3) { [ stdout_msg, stderr_msg,  $? ] }
          allow_any_instance_of(Process::Status).to receive(:success?) { false }
          Ddr::Jobs::FitsFileCharacterization.perform(object.pid)
          object.reload
        end
        it "should not populate the fits datastream" do
          expect(object.fits.content).to_not be_present
        end
        it_behaves_like "has a fits update event"
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddr-models-2.3.2 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.3.1 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.3.0 spec/jobs/fits_file_characterization_spec.rb
ddr-models-3.0.0.alpha.2 spec/jobs/fits_file_characterization_spec.rb
ddr-models-3.0.0.alpha.1 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.2.0 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.1.3 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.1.2 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.1.1 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.1.0 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.1.0.rc2 spec/jobs/fits_file_characterization_spec.rb
ddr-models-2.1.0.rc1 spec/jobs/fits_file_characterization_spec.rb