CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/support/shared/contexts/rex/job/inline.rb
Views: 1904
1
RSpec.shared_context 'Rex::Job#start run inline' do
2
# Intercepts calls to Rex::Job objects, and ensures that async rex jobs are immediately run inline instead of having
3
# their execution deferred until later. This ensures that Jobs deterministically complete during a test run.
4
def run_rex_jobs_inline!
5
allow_any_instance_of(Rex::Job).to receive(:start).and_wrap_original do |original_method, original_async_value|
6
original_receiver = original_method.receiver
7
ctx = original_receiver.ctx
8
if ctx.first.is_a?(Msf::Module)
9
mod = ctx.first
10
mod.print_status("Running rex job #{original_receiver.jid} inline")
11
end
12
expect(original_async_value).to be(true)
13
new_async_value = false
14
original_method.call(new_async_value)
15
end
16
end
17
end
18
19