Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/plugins/capture_spec.rb
Views: 11766
require 'spec_helper'1require Metasploit::Framework.root.join('plugins/capture.rb').to_path23RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher do4include_context 'Msf::UIDriver'56let(:framework) { instance_double(Msf::Framework) }78describe '#cmd_captureg' do9subject { described_class.new(driver) }1011context 'when called without args' do12it 'returns generic help text' do13expect(subject.cmd_captureg).to eql subject.help14end15end1617context 'when there is a single arg matching the HELP regex' do18it 'returns generic help text' do19expect(subject.cmd_captureg('--help')).to eql subject.help20end21end2223context 'when there are two args with first one matching the HELP regex' do24it 'calls `help` with second arg' do25expect(subject.cmd_captureg('--help', 'start')).to eql subject.help('start')26end27end28end29end3031RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher::CaptureJobListener do32include_context 'Msf::UIDriver'33let(:dispatcher) { instance_double(Msf::Plugin::Capture::ConsoleCommandDispatcher) }34let(:done_event) { instance_double(Rex::Sync::Event, set: nil) }35let(:name) { 'my-little-module' }3637subject { described_class.new(name, done_event, dispatcher) }3839before(:each) do40capture_logging(dispatcher)41end4243describe '#waiting' do44it 'sets the `succeeded` flag' do45subject.waiting('ignored')4647expect(subject.succeeded).to eql true48end4950it 'outputs a message via the dispatcher' do51subject.waiting('ignored')5253expect(@output).to include("#{name} started")54end5556it 'sets the done event' do57expect(done_event).to receive(:set)5859subject.waiting('ignored')60end61end6263describe '#failed' do64it 'outputs a message via the dispatcher' do65subject.failed('ignored', 'ignored', 'ignored')6667expect(@error).to include("#{name} failed to start")68end6970it 'sets the done event' do71expect(done_event).to receive(:set)7273subject.failed('ignored', 'ignored', 'ignored')74end75end76end777879