homebrew-cask-versions/test/support/fake_system_command.rb
Paul Hinze 3991bd6839 a beta pkg installer
- the vagrant cask is our guinea pig
- works for me
- only basic testing at the moment
- i wanted to push something to get the gears turning on this

it turns out the concept is pretty simple. specify a list of pkgs to
install; borrow the patterns from linkables for that. then basically
just run "sudo installer"

refs #14
2013-05-11 23:01:59 -05:00

45 lines
848 B
Ruby

class Cask::FakeSystemCommand
def self.fake_response_for(command, response='')
@responses ||= {}
@responses[command] = response
end
def self.system_calls
@system_calls
end
def self.init
@responses = {}
end
def self.clear
@responses = {}
@system_calls = Hash.new(0)
end
def self.run(command)
@responses ||= {}
@system_calls ||= Hash.new(0)
unless @responses.key?(command)
fail("no response faked for #{command.inspect}, faked responses are: #{@responses.inspect}")
end
@system_calls[command] += 1
@responses[command].split("\n")
end
end
module FakeSystemCommandHooks
def before_setup
Cask::FakeSystemCommand.init
super
end
def after_teardown
super
Cask::FakeSystemCommand.clear
end
end
class MiniTest::Spec
include FakeSystemCommandHooks
end