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/support/shared/contexts/msf/ui_driver.rb
Views: 11788
RSpec.shared_context 'Msf::UIDriver' do1let(:driver) do2instance = double('Driver', framework: framework)3allow(instance).to receive(:on_command_proc=).with(kind_of(Proc))4capture_logging(instance)5instance6end78let(:driver_input) do9double(Rex::Ui::Text::Input)10end1112let(:driver_output) do13instance = double(14Rex::Ui::Text::Output,15prompting?: false,16prompting: false17)1819capture_logging(instance)20instance21end2223def reset_logging!24@output = []25@error = []26@combined_output = []27end2829def capture_logging(target)30append_output = proc do |string = ''|31lines = string.split("\n")32@output ||= []33@output.concat(lines)34@combined_output ||= []35@combined_output.concat(lines)36end37append_error = proc do |string = ''|38lines = string.split("\n")39@error ||= []40@error.concat(lines)41@combined_output ||= []42@combined_output.concat(lines)43end4445allow(target).to receive(:print, &append_output)46allow(target).to receive(:print_line, &append_output)47allow(target).to receive(:print_status, &append_output)48allow(target).to receive(:print_good, &append_output)4950allow(target).to receive(:print_warning, &append_error)51allow(target).to receive(:print_error, &append_error)52allow(target).to receive(:print_bad, &append_error)53end54end555657