Module: Scmd
- Defined in:
- lib/scmd/command.rb,
lib/scmd.rb,
lib/scmd/version.rb,
lib/scmd/command_spy.rb,
lib/scmd/stored_commands.rb
Overview
Scmd::Command is a base wrapper for handling system commands. Initialize it with with a string specifying the command to execute. You can then run the command and inspect its results. It can be used as is, or inherited from to create a more custom command wrapper.
Defined Under Namespace
Classes: Call, Command, CommandSpy, RunError, StoredCommands
Constant Summary
collapse
- TimeoutError =
Class.new(::RuntimeError)
- VERSION =
"3.0.5"
Class Method Summary
collapse
Class Method Details
.add_command(cmd_str, &block) ⇒ Object
40
41
42
|
# File 'lib/scmd.rb', line 40
def self.add_command(cmd_str, &block)
commands.add(cmd_str, &block)
end
|
.calls ⇒ Object
29
30
31
32
|
# File 'lib/scmd.rb', line 29
def self.calls
raise NoMethodError unless ENV["SCMD_TEST_MODE"]
@calls ||= []
end
|
.commands ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/scmd.rb', line 20
def self.commands
raise NoMethodError unless ENV["SCMD_TEST_MODE"]
@commands ||=
begin
require "scmd/stored_commands"
StoredCommands.new
end
end
|
.new(*args) ⇒ Object
Scmd can be run in “test mode”. This means that command spies will be used in place of “live” commands, each time a command is run or started will be logged in a collection and option-specific spies can be added and used to “stub” spies with specific attributes in specific contexts.
12
13
14
15
16
17
18
|
# File 'lib/scmd.rb', line 12
def self.new(*args)
if !ENV["SCMD_TEST_MODE"]
Command.new(*args)
else
commands.get(*args)
end
end
|
.reset ⇒ Object
34
35
36
37
38
|
# File 'lib/scmd.rb', line 34
def self.reset
raise NoMethodError unless ENV["SCMD_TEST_MODE"]
calls.clear
commands.remove_all
end
|