Sha256: 66c477533cd15c8d601fb74ca46fcb8506068a9ee26f5fd9a0eaf382b1ae9cfd

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

good_path = 'README.md'
bad_path = 'BAD_FILE.md'

describe Clamby do
  it "should find files." do
    expect(Clamby.file_exists?(good_path)).to be true
  end

  it "should find clamscan" do
    expect(Clamby.scanner_exists?).to be true
  end

  it "should not find files." do
    Clamby.configure({:error_file_missing => true})
    expect{Clamby.file_exists?(bad_path)}.to raise_exception(Exceptions::FileNotFound)
    Clamby.configure({:error_file_missing => false})
    expect(Clamby.file_exists?(bad_path)).to be false
  end

  it "should scan file as safe" do
    expect(Clamby.safe?(good_path)).to be true
    expect(Clamby.virus?(good_path)).to be false
  end

  it "should scan file and return nil" do
    expect(Clamby.safe?(bad_path)).to be nil
    expect(Clamby.virus?(bad_path)).to be nil
  end

  it "should scan file as dangerous" do
     `which wget`

     if $?.success?
      `wget http://www.eicar.org/download/eicar.com`
     else
      `curl http://www.eicar.org/download/eicar.com > eicar.com`
    end
    `chmod 644 eicar.com`
    Clamby.configure({:error_file_virus => true})
    expect{Clamby.safe?('eicar.com')}.to raise_exception(Exceptions::VirusDetected)
    expect{Clamby.virus?('eicar.com')}.to raise_exception(Exceptions::VirusDetected)
    Clamby.configure({:error_file_virus => false})
    expect(Clamby.safe?('eicar.com')).to be false
    expect(Clamby.virus?('eicar.com')).to be true
    File.delete('eicar.com')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
clamby-1.2.4 spec/clamby_spec.rb
clamby-1.2.3 spec/clamby_spec.rb
clamby-1.2.2 spec/clamby_spec.rb
clamby-1.2.1 spec/clamby_spec.rb