From 3d2b6c9c22e8bdc50ea7eb96084601a0366a4437 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 17 Jan 2020 10:56:35 -0700 Subject: Add spec to test nuget package scanning in sub directories --- spec/integration/dotnet/nuget_spec.rb | 34 +++++++++++++++++++++++++++++++++ spec/support/integration_test_helper.rb | 3 ++- 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/integration/dotnet/nuget_spec.rb b/spec/integration/dotnet/nuget_spec.rb index 73fab09..8c2b727 100644 --- a/spec/integration/dotnet/nuget_spec.rb +++ b/spec/integration/dotnet/nuget_spec.rb @@ -41,4 +41,38 @@ RSpec.describe ".NET Framework" do ]) end end + + context "when a project has multiple nuget packages.config in different sub directories" do + let(:console_packages) do + <<-XML + + + + + XML + end + + let(:winforms_packages) do + <<-XML + + + + + XML + end + + it 'produces a report including dependencies from each sub directory' do + runner.add_file('console/packages.config', console_packages) + runner.add_file('winforms/packages.config', winforms_packages) + report = runner.scan(env: { 'LICENSE_FINDER_CLI_OPTS' => '--recursive' }) + + expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') + expect(report[:licenses].count).not_to be_zero + expect(report[:dependencies].map { |x| x[:name] }).to match_array([ + "jive", + "MvcMailer", + ]) + end + end end diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb index 5ef00a1..e05ef43 100644 --- a/spec/support/integration_test_helper.rb +++ b/spec/support/integration_test_helper.rb @@ -8,7 +8,8 @@ module IntegrationTestHelper end def add_file(name, content = nil) - full_path = "#{project_path}/#{name}" + full_path = Pathname.new("#{project_path}/#{name}") + FileUtils.mkdir_p(full_path.dirname) IO.write(full_path, block_given? ? yield : content) end -- cgit v1.2.3