spec/support/shell_mock.rb in waddup-0.2.1 vs spec/support/shell_mock.rb in waddup-0.2.2
- old
+ new
@@ -12,15 +12,15 @@
end
# Applies shell mock functionality
def self.apply!
- Object.any_instance.stub(:`).and_return do |foo|
- raise ShellNotAllowedError, foo
+ Object.any_instance.stub(:`) do |object, command|
+ raise ShellNotAllowedError, command
end
- Object.any_instance.stub(:system).and_return do |command|
+ Object.any_instance.stub(:system) do |object, command|
raise ShellNotAllowedError, command
end
end
end
@@ -35,19 +35,19 @@
#
def stub_shell(command, options = {})
output = options.delete(:output) || ''
exitstatus = options.delete(:exitstatus) || 0
- block = lambda {
+ block = lambda { |command|
if exitstatus.nonzero?
Kernel.send :`, "test"
else
Kernel.send :`, "test success"
end
output
}
- stub(:`).with(command).and_return &block
- stub(:system).with(command).and_return &block
+ stub(:`).with(command, &block)
+ stub(:system).with(command, &block)
end
end