From 58ff80dfdd7e050e151f77b08625977c54f48e07 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 26 Mar 2013 21:59:25 -0300 Subject: [PATCH] Prevent `exec` and `fork` on unit specs --- spec/support/unit_example_group.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/support/unit_example_group.rb b/spec/support/unit_example_group.rb index 8ba8241..06a1e6f 100644 --- a/spec/support/unit_example_group.rb +++ b/spec/support/unit_example_group.rb @@ -8,6 +8,12 @@ module UnitExampleGroup Object.any_instance.stub(:`) { |*args, &block| UnitExampleGroup.prevent_system_calls(*args, &block) } + Object.any_instance.stub(:exec) { |*args, &block| + UnitExampleGroup.prevent_system_calls(*args, &block) + } + Object.any_instance.stub(:fork) { |*args, &block| + UnitExampleGroup.prevent_system_calls(*args, &block) + } require 'vagrant/util/subprocess' Vagrant::Util::Subprocess.stub(:execute) { |*args, &block| UnitExampleGroup.prevent_system_calls(*args, &block) @@ -22,6 +28,7 @@ module UnitExampleGroup Somehow your code under test is trying to execute a command on your system, please stub it out or move your spec code to an acceptance spec. +Block: #{block.inspect} Command: "#{args.join(' ')}" MSG end