Module: ShellMock
- Defined in:
- lib/shell_mock.rb,
lib/shell_mock/version.rb,
lib/shell_mock/command_stub.rb,
lib/shell_mock/monkey_patch.rb,
lib/shell_mock/call_verifier.rb,
lib/shell_mock/stub_registry.rb,
lib/shell_mock/rspec/matchers.rb,
lib/shell_mock/exec_monkey_patch.rb,
lib/shell_mock/no_stub_specified.rb,
lib/shell_mock/spawn_monkey_patch.rb,
lib/shell_mock/system_monkey_patch.rb,
lib/shell_mock/backtick_monkey_patch.rb
Defined Under Namespace
Modules: Matchers
Classes: BacktickMonkeyPatch, CallVerifier, CommandStub, ExecMonkeyPatch, MonkeyPatch, NoStubSpecified, SpawnMonkeyPatch, SystemMonkeyPatch
Constant Summary
collapse
- VERSION =
"0.5.0"
- StubRegistry =
Object.new
Class Method Summary
collapse
Class Method Details
.disable ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/shell_mock.rb', line 40
def self.disable
ShellMock.monkey_patches.each(&:disable)
StubRegistry.clear
@enabled = false
true
end
|
.dont_let_commands_run ⇒ Object
18
19
20
|
# File 'lib/shell_mock.rb', line 18
def self.dont_let_commands_run
@let_commands_run = false
end
|
.dont_let_commands_run? ⇒ Boolean
smell; this is a mistake of a method that will only confuse people
28
29
30
|
# File 'lib/shell_mock.rb', line 28
def self.dont_let_commands_run?
!let_commands_run?
end
|
.enable ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/shell_mock.rb', line 32
def self.enable
ShellMock.monkey_patches.each(&:enable)
@enabled = true
true
end
|
.enabled? ⇒ Boolean
50
51
52
|
# File 'lib/shell_mock.rb', line 50
def self.enabled?
@enabled
end
|
.let_commands_run ⇒ Object
14
15
16
|
# File 'lib/shell_mock.rb', line 14
def self.let_commands_run
@let_commands_run = true
end
|
.let_commands_run? ⇒ Boolean
22
23
24
25
|
# File 'lib/shell_mock.rb', line 22
def self.let_commands_run?
@let_commands_run = true if @let_commands_run.nil?
@let_commands_run
end
|
.monkey_patches ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/shell_mock.rb', line 54
def self.monkey_patches
@monkey_patches ||= [
SpawnMonkeyPatch.new,
SystemMonkeyPatch.new,
ExecMonkeyPatch.new,
BacktickMonkeyPatch.new,
]
end
|
.stub_command(command) ⇒ Object
8
9
10
11
12
|
# File 'lib/shell_mock.rb', line 8
def self.stub_command(command)
command_stub = CommandStub.new(command)
StubRegistry.register_command_stub(command_stub)
end
|