diff options
| author | mo khan <mo.khan@gmail.com> | 2020-01-17 10:56:35 -0700 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-01-17 10:56:35 -0700 |
| commit | 3d2b6c9c22e8bdc50ea7eb96084601a0366a4437 (patch) | |
| tree | 66cba50b9bc3d0baa8cffae0210464aeece43855 | |
| parent | 45d4a0c9040e913a458312c7bee5b362713b6e78 (diff) | |
Add spec to test nuget package scanning in sub directories
| -rw-r--r-- | spec/integration/dotnet/nuget_spec.rb | 34 | ||||
| -rw-r--r-- | spec/support/integration_test_helper.rb | 3 |
2 files changed, 36 insertions, 1 deletions
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 version="1.0" encoding="utf-8"?> +<packages> + <package id="jive" version="0.1.0" /> +</packages> + XML + end + + let(:winforms_packages) do + <<-XML +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="MvcMailer" version="4.5.0" /> +</packages> + 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 |
