diff options
| author | mo khan <mo.khan@gmail.com> | 2020-09-14 16:11:33 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-09-14 16:11:33 -0600 |
| commit | cea7d78e2d7f1a8f98880819b8589925b5daef1a (patch) | |
| tree | 826d3288962b0925cc291602b72153a26c45b46b /spec | |
| parent | 018f54f7af434dfaadfdfb36687a59e2069b7a8c (diff) | |
Write a test to scan a java project
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/gemnasium_maven_spec.rb | 21 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/spec/gemnasium_maven_spec.rb b/spec/gemnasium_maven_spec.rb new file mode 100644 index 0000000..63c9aae --- /dev/null +++ b/spec/gemnasium_maven_spec.rb @@ -0,0 +1,21 @@ +RSpec.describe 'gemnasium-maven' do + context "when scanning a java project with packages from a custom source" do + subject do + Dir.chdir Pathname.pwd.join('src/gemnasium-maven') do + system("docker build --network=host -t #{docker_image} .") + + if system([ :docker, :run, '-it', '--rm', '--volume', "#{project_path}:/tmp/app", '--network=host', '--env', 'CI_PROJECT_DIR=/tmp/app', docker_image, '/analyzer run' ].map(&:to_s).join(' ')) + report_path = project_path.join('gl-license-scanning-report.json') + report_path.exist? ? JSON.parse(report_path.read) : {} + else + {} + end + end + end + + let(:project_path) { Dir.pwd } + let(:docker_image) { 'gemnasium-maven:latest' } + + specify { expect(subject.count).to eql(1) } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 251aa51..8cfc067 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,8 @@ # it. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require 'json' + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest |
