Commit 39eaadd
Changed files (3)
spec
spec/integration/scan_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe '`spandx scan` command', type: :cli do
end
it 'executes `spandx scan Gemfile.lock`' do
- gemfile_lock = File.join(Dir.pwd, 'spec', 'fixtures', 'bundler', 'Gemfile-single.lock')
+ gemfile_lock = fixture_file('bundler/Gemfile-single.lock')
output = `spandx scan #{gemfile_lock}`
expected_output = <<~OUT
{
@@ -37,7 +37,7 @@ RSpec.describe '`spandx scan` command', type: :cli do
end
it 'executes `spandx scan gems.lock' do
- gemfile_lock = File.join(Dir.pwd, 'spec', 'fixtures', 'bundler', 'gems-single.lock')
+ gemfile_lock = fixture_file('bundler/gems-single.lock')
output = `spandx scan #{gemfile_lock}`
expected_output = <<~OUT
{
@@ -57,7 +57,7 @@ RSpec.describe '`spandx scan` command', type: :cli do
end
it 'executes `spandx scan Pipfile.lock`' do
- lockfile = File.join(Dir.pwd, 'spec', 'fixtures', 'pip', 'Pipfile.lock')
+ lockfile = fixture_file('pip/Pipfile.lock')
output = `spandx scan #{lockfile}`
expected_output = <<~OUT
{
spec/unit/scan_spec.rb
@@ -1,13 +1,25 @@
# frozen_string_literal: true
RSpec.describe Spandx::Commands::Scan do
- it 'executes `scan` command successfully' do
- output = StringIO.new
- options = {}
- command = described_class.new(nil, options)
+ subject { described_class.new(lockfile, options) }
+
+ let(:output) { StringIO.new }
+ let(:lockfile) { nil }
+ let(:options) { {} }
- command.execute(output: output)
+ it 'executes `scan` command successfully' do
+ subject.execute(output: output)
expect(output.string).to eq("OK\n")
end
+
+ context "when scanning Gemfile.lock" do
+ let(:lockfile) { fixture_file('bundler/Gemfile-single.lock') }
+
+ it 'produces the proper report' do
+ subject.execute(output: output)
+
+ expect(output.string).to eq("OK\n")
+ end
+ end
end
spec/spec_helper.rb
@@ -9,6 +9,11 @@ require 'securerandom'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
+ config.include(Module.new do
+ def fixture_file(file)
+ File.join(Dir.pwd, 'spec', 'fixtures', file)
+ end
+ end)
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!