mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-09-25 10:48:31 +02:00
Tidy up plugin specs
This commit is contained in:
parent
a0bdbce3c9
commit
5974801e14
@ -2,29 +2,26 @@ require 'spec_helper'
|
||||
require Metasploit::Framework.root.join('plugins/capture.rb').to_path
|
||||
|
||||
RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher do
|
||||
describe '#cmd_captureg' do
|
||||
let(:driver) do
|
||||
double(Object).as_null_object.tap do |dbl|
|
||||
allow(dbl).to receive(:print_line) do |args|
|
||||
args
|
||||
end
|
||||
end
|
||||
end
|
||||
include_context 'Msf::UIDriver'
|
||||
|
||||
let(:framework) { instance_double(Msf::Framework) }
|
||||
|
||||
describe '#cmd_captureg' do
|
||||
subject { described_class.new(driver) }
|
||||
context 'without args' do
|
||||
|
||||
context 'when called without args' do
|
||||
it 'returns generic help text' do
|
||||
expect(subject.cmd_captureg).to eql subject.help
|
||||
end
|
||||
end
|
||||
|
||||
context 'single arg matching the HELP regex' do
|
||||
context 'when there is a single arg matching the HELP regex' do
|
||||
it 'returns generic help text' do
|
||||
expect(subject.cmd_captureg('--help')).to eql subject.help
|
||||
end
|
||||
end
|
||||
|
||||
context 'two args, first one matches HELP regex' do
|
||||
context 'when there are two args with first one matching the HELP regex' do
|
||||
it 'calls `help` with second arg' do
|
||||
expect(subject.cmd_captureg('--help', 'start')).to eql subject.help('start')
|
||||
end
|
||||
@ -33,18 +30,17 @@ RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher do
|
||||
end
|
||||
|
||||
RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher::CaptureJobListener do
|
||||
let(:dispatcher) do
|
||||
instance_double(
|
||||
Msf::Plugin::Capture::ConsoleCommandDispatcher,
|
||||
print_error: nil,
|
||||
print_good: nil
|
||||
)
|
||||
end
|
||||
include_context 'Msf::UIDriver'
|
||||
let(:dispatcher) { instance_double(Msf::Plugin::Capture::ConsoleCommandDispatcher) }
|
||||
let(:done_event) { instance_double(Rex::Sync::Event, set: nil) }
|
||||
let(:name) { 'my-little-module' }
|
||||
|
||||
subject { described_class.new(name, done_event, dispatcher) }
|
||||
|
||||
before(:each) do
|
||||
capture_logging(dispatcher)
|
||||
end
|
||||
|
||||
describe '#waiting' do
|
||||
it 'sets the `succeeded` flag' do
|
||||
subject.waiting('ignored')
|
||||
@ -53,9 +49,9 @@ RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher::CaptureJobListene
|
||||
end
|
||||
|
||||
it 'outputs a message via the dispatcher' do
|
||||
expect(dispatcher).to receive(:print_good).with("#{name} started")
|
||||
|
||||
subject.waiting('ignored')
|
||||
|
||||
expect(@output).to include("#{name} started")
|
||||
end
|
||||
|
||||
it 'sets the done event' do
|
||||
@ -67,9 +63,9 @@ RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher::CaptureJobListene
|
||||
|
||||
describe '#failed' do
|
||||
it 'outputs a message via the dispatcher' do
|
||||
expect(dispatcher).to receive(:print_error).with("#{name} failed to start")
|
||||
|
||||
subject.failed('ignored', 'ignored', 'ignored')
|
||||
|
||||
expect(@error).to include("#{name} failed to start")
|
||||
end
|
||||
|
||||
it 'sets the done event' do
|
||||
|
Loading…
Reference in New Issue
Block a user