We have the following Parallel block which spin up multiple parallel processes
Parallel.map(
servers,
:in_processes => servers.size,
:preserve_results => false,
) do |server|
downtime(server)
server.destroy
server.create
server.init
cancel_downtime(server)
end
It turns out to be impossible to verify the order of these steps in our spec
Added the following lines in before(:each)
block
Parallel.stub(:work_in_threads) { |arr, opts, &block| Parallel.send(:work_direct, arr, opts, &block) }
Parallel.stub(:work_in_processes) { |arr, opts, &block| Parallel.send(:work_direct, arr, opts, &block) }
Then happily proceed with our test
server.should_receive(:disable_monitoring).ordered
server.should_receive(:destroy).ordered
server.should_receive(:create).ordered
server.should_receive(:enable_monitoring).ordered