2015-12-24 10:55:13 -08:00
|
|
|
require 'spec_helper'
|
2015-12-23 12:53:12 -08:00
|
|
|
|
2021-01-29 17:59:14 +00:00
|
|
|
require Metasploit::Framework.root.join('tools/dev/msftidy.rb').to_path
|
2015-12-23 12:53:12 -08:00
|
|
|
|
2015-12-24 10:55:13 -08:00
|
|
|
RSpec.describe Msftidy do
|
2021-01-29 17:59:14 +00:00
|
|
|
let(:file) { File.expand_path('modules/auxiliary/auxiliary_rubocopped.rb', FILE_FIXTURES_PATH) }
|
|
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
|
allow_any_instance_of(MsftidyRunner).to receive(:run_checks)
|
|
|
|
|
allow_any_instance_of(MsftidyRunner).to receive(:status).and_return(msftidy_runner_status_code)
|
|
|
|
|
allow_any_instance_of(RuboCopRunner).to receive(:run).and_return(rubocop_runner_status_code)
|
2015-12-23 12:53:12 -08:00
|
|
|
end
|
|
|
|
|
|
2021-01-29 17:59:14 +00:00
|
|
|
context 'when there are no errors' do
|
|
|
|
|
let(:msftidy_runner_status_code) { MsftidyRunner::OK }
|
|
|
|
|
let(:rubocop_runner_status_code) { RuboCop::CLI::STATUS_SUCCESS }
|
2015-12-24 10:55:13 -08:00
|
|
|
|
2021-01-29 17:59:14 +00:00
|
|
|
it { expect(subject.run([file])).to eql MsftidyRunner::OK }
|
|
|
|
|
end
|
2015-12-23 12:53:12 -08:00
|
|
|
|
2021-01-29 17:59:14 +00:00
|
|
|
context 'when there are msftidy errors' do
|
|
|
|
|
let(:msftidy_runner_status_code) { MsftidyRunner::WARNING }
|
|
|
|
|
let(:rubocop_runner_status_code) { RuboCop::CLI::STATUS_SUCCESS }
|
2015-12-24 10:55:13 -08:00
|
|
|
|
2021-01-29 17:59:14 +00:00
|
|
|
it { expect(subject.run([file])).to eql MsftidyRunner::WARNING }
|
2015-12-23 12:53:12 -08:00
|
|
|
end
|
|
|
|
|
|
2021-01-29 17:59:14 +00:00
|
|
|
context 'when there are rubcop errors' do
|
|
|
|
|
let(:msftidy_runner_status_code) { MsftidyRunner::WARNING }
|
|
|
|
|
let(:rubocop_runner_status_code) { RuboCop::CLI::STATUS_ERROR }
|
2015-12-23 12:53:12 -08:00
|
|
|
|
2021-01-29 17:59:14 +00:00
|
|
|
it { expect(subject.run([file])).to eql MsftidyRunner::ERROR }
|
2015-12-23 12:53:12 -08:00
|
|
|
end
|
|
|
|
|
end
|