Skip to content

Commit

Permalink
update specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesaelim committed May 6, 2024
1 parent aa01189 commit d2a81a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions spec/database_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require 'spec_helper'

describe RubyAudit::Database do
describe '#check_library' do
let(:library) { RubyAudit::Scanner::Version.new('rubygems', '2.4.5') }
describe '#check_rubygems' do
let(:rubygems) { RubyAudit::Scanner::Version.new('rubygems-update', '2.4.5') }

context 'when given a block' do
it 'should yield every advisory affecting the library' do
it 'should yield every advisory affecting the rubygems version' do
advisories = []

subject.check_library(library) do |advisory|
subject.check_rubygems(rubygems) do |advisory|
advisories << advisory
end

Expand All @@ -17,14 +17,14 @@
advisory.is_a?(Bundler::Audit::Advisory)
end).to be_truthy
expect(advisories.map(&:id)).to include('CVE-2015-3900')
expect(advisories.map(&:path).reject { |p| p =~ /libraries/ })
expect(advisories.map(&:path).reject { |p| p =~ /rubygems-update/ })
.to be_empty
end
end

context 'when given no block' do
it 'should return an Enumerator' do
expect(subject.check_library(library)).to be_kind_of(Enumerable)
expect(subject.check_rubygems(rubygems)).to be_kind_of(Enumerable)
end
end
end
Expand All @@ -44,7 +44,7 @@
expect(advisories.all? do |advisory|
advisory.is_a?(Bundler::Audit::Advisory)
end).to be_truthy
expect(advisories.map(&:id)).to include('OSVDB-120541')
expect(advisories.map(&:id)).to include('CVE-2015-1855')
expect(advisories.map(&:path).reject { |p| p =~ /rubies/ }).to be_empty
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/scanner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
expect(subject.all? do |result|
result.advisory.vulnerable?(result.gem.version)
end).to be_truthy
expect(subject.map { |r| r.advisory.id }).to include('OSVDB-120541')
expect(subject.map { |r| r.advisory.id }).to include('CVE-2015-1855')
end

it 'respects patch level' do
stub_const('RUBY_VERSION', '1.9.3')
stub_const('RUBY_PATCHLEVEL', 392)
expect(subject.map { |r| r.advisory.id }).to include('OSVDB-113747')
expect(subject.map { |r| r.advisory.id }).to include('CVE-2014-8080')
end

it 'handles preview versions' do
stub_const('RUBY_VERSION', '2.1.0')
stub_const('RUBY_PATCHLEVEL', -1)
allow_any_instance_of(RubyAudit::Scanner)
.to receive(:ruby_version).and_return('2.1.0.dev')
expect(subject.map { |r| r.advisory.id }).to include('OSVDB-100113')
expect(subject.map { |r| r.advisory.id }).to include('CVE-2013-4164')
end

context 'when the :ignore option is given' do
subject { scanner.scan(ignore: ['OSVDB-120541']) }
subject { scanner.scan(ignore: ['CVE-2015-1855']) }

it 'should ignore the specified advisories' do
expect(subject.map { |r| r.advisory.id }).not_to include('OSVDB-120541')
expect(subject.map { |r| r.advisory.id }).not_to include('CVE-2015-1855')
end
end
end
Expand Down

0 comments on commit d2a81a0

Please sign in to comment.