summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/integration/core/cache_spec.rb36
1 files changed, 6 insertions, 30 deletions
diff --git a/spec/integration/core/cache_spec.rb b/spec/integration/core/cache_spec.rb
index 6c23f14..ec1a8b2 100644
--- a/spec/integration/core/cache_spec.rb
+++ b/spec/integration/core/cache_spec.rb
@@ -1,18 +1,15 @@
# frozen_string_literal: true
RSpec.describe Spandx::Core::Cache do
- subject { described_class.new(package_manager, url: url) }
+ RSpec.shared_examples 'each data file' do |package_manager, url|
+ describe "#licenses_for (#{package_manager})" do
+ subject { described_class.new(package_manager, url: url) }
- context 'rubygems' do
- let(:package_manager) { :rubygems }
- let(:url) { "https://github.com/mokhan/spandx-#{package_manager}.git" }
-
- describe '#licenses_for' do
(0x00..0xFF).map { |x| x.to_s(16).upcase.rjust(2, '0').downcase }.each do |hex|
context hex do
let(:path) { subject.db.expand_path(".index/#{hex}/#{package_manager}") }
- it 'is able to find all packages in the index' do
+ it "is able to find all packages in the #{package_manager} index" do
CSV.foreach(path) do |row|
results = subject.licenses_for(name: row[0], version: row[1])
expect(results).to match_array(row[2].split('-|-'))
@@ -27,27 +24,6 @@ RSpec.describe Spandx::Core::Cache do
end
end
- context 'nuget' do
- let(:package_manager) { :nuget }
- let(:url) { 'https://github.com/mokhan/spandx-index.git' }
-
- describe '#licenses_for' do
- (0x00..0xFF).map { |x| x.to_s(16).upcase.rjust(2, '0').downcase }.each do |hex|
- context hex do
- let(:path) { subject.db.expand_path(".index/#{hex}/#{package_manager}") }
-
- it 'is able to find all packages in the index' do
- CSV.foreach(path) do |row|
- results = subject.licenses_for(name: row[0], version: row[1])
- expect(results).to match_array(row[2].split('-|-'))
- end
- end
- end
- end
-
- it 'returns an empty list of unknown packages' do
- expect(subject.licenses_for(name: 'x', version: 'x')).to be_empty
- end
- end
- end
+ include_examples 'each data file', 'rubygems', 'https://github.com/mokhan/spandx-rubygems.git'
+ include_examples 'each data file', 'nuget', 'https://github.com/mokhan/spandx-index.git'
end