Sha256: 1ee866e8cc546140045854213319c92cacf53a449d15ade987ee35ff876a4918
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
module UnitExampleGroup def self.included(base) base.metadata[:type] = :unit base.before do Object.any_instance.stub(:system) { |*args, &block| UnitExampleGroup.prevent_system_calls(*args, &block) } 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) } Object.any_instance.stub(:spawn) { |*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) } end end def self.prevent_system_calls(*args, &block) args.pop if args.last.is_a?(Hash) raise <<-MSG 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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
docker-provider-0.1.0 | spec/support/unit_example_group.rb |
docker-provider-0.0.2 | spec/support/unit_example_group.rb |
docker-provider-0.0.1 | spec/support/unit_example_group.rb |