Path: blob/master/spec/support/shared/contexts/rex/job/inline.rb
19812 views
RSpec.shared_context 'Rex::Job#start run inline' do1# Intercepts calls to Rex::Job objects, and ensures that async rex jobs are immediately run inline instead of having2# their execution deferred until later. This ensures that Jobs deterministically complete during a test run.3def run_rex_jobs_inline!4allow_any_instance_of(Rex::Job).to receive(:start).and_wrap_original do |original_method, original_async_value|5original_receiver = original_method.receiver6ctx = original_receiver.ctx7if ctx.first.is_a?(Msf::Module)8mod = ctx.first9mod.print_status("Running rex job #{original_receiver.jid} inline")10end11expect(original_async_value).to be(true)12new_async_value = false13original_method.call(new_async_value)14end15end16end171819