Sha256: 7f98ab1282438089ce20730ac7eb664570b199c181d510437718ce1040926e2e
Contents?: true
Size: 1.24 KB
Versions: 6
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' describe Hydra::Works::VirusCheck do before do class FileWithVirusCheck < ActiveFedora::Base include Hydra::Works::FileSetBehavior include Hydra::Works::VirusCheck end class ClamAV def self.instance @instance ||= ClamAV.new end def scanfile(path) puts "scanfile: #{path}" end end end after do Object.send(:remove_const, :ClamAV) Object.send(:remove_const, :FileWithVirusCheck) end subject { FileWithVirusCheck.new } let(:file) { Hydra::PCDM::File.new File.join(fixture_path, 'sample-file.pdf') } before do allow(subject).to receive(:original_file) { file } allow(subject).to receive(:warn) # suppress virus warning messages end context 'with an infected file' do before do expect(ClamAV.instance).to receive(:scanfile).and_return(1) end it 'fails to save' do expect(subject.save).to eq false end it 'fails to validate' do expect(subject.validate).to eq false end end context 'with a clean file' do before do expect(ClamAV.instance).to receive(:scanfile).and_return(0) end it 'does not detect viruses' do expect(subject.detect_viruses).to eq true end end end
Version data entries
6 entries across 6 versions & 1 rubygems