Class: ShellMock::CommandStub
- Inherits:
-
Object
- Object
- ShellMock::CommandStub
- Defined in:
- lib/shell_mock/command_stub.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#exitstatus ⇒ Object
readonly
Returns the value of attribute exitstatus.
-
#expected_output ⇒ Object
readonly
Returns the value of attribute expected_output.
Instance Method Summary collapse
- #and_exit(exitstatus) ⇒ Object
- #and_return(expected_output) ⇒ Object
- #called_with(env, command, options) ⇒ Object
- #calls ⇒ Object
- #env ⇒ Object
-
#initialize(command) ⇒ CommandStub
constructor
A new instance of CommandStub.
- #options ⇒ Object
- #side_effect ⇒ Object
- #with_env(env) ⇒ Object
- #with_option(option) ⇒ Object
Constructor Details
#initialize(command) ⇒ CommandStub
Returns a new instance of CommandStub.
7 8 9 |
# File 'lib/shell_mock/command_stub.rb', line 7 def initialize(command) @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/shell_mock/command_stub.rb', line 5 def command @command end |
#exitstatus ⇒ Object (readonly)
Returns the value of attribute exitstatus.
5 6 7 |
# File 'lib/shell_mock/command_stub.rb', line 5 def exitstatus @exitstatus end |
#expected_output ⇒ Object (readonly)
Returns the value of attribute expected_output.
5 6 7 |
# File 'lib/shell_mock/command_stub.rb', line 5 def expected_output @expected_output end |
Instance Method Details
#and_exit(exitstatus) ⇒ Object
38 39 40 41 42 |
# File 'lib/shell_mock/command_stub.rb', line 38 def and_exit(exitstatus) @exitstatus = exitstatus self end |
#and_return(expected_output) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/shell_mock/command_stub.rb', line 31 def and_return(expected_output) @expected_output = expected_output @exitstatus ||= 0 self end |
#called_with(env, command, options) ⇒ Object
52 53 54 |
# File 'lib/shell_mock/command_stub.rb', line 52 def called_with(env, command, ) calls << [env, command, ] end |
#calls ⇒ Object
48 49 50 |
# File 'lib/shell_mock/command_stub.rb', line 48 def calls @calls ||= [] end |
#env ⇒ Object
17 18 19 |
# File 'lib/shell_mock/command_stub.rb', line 17 def env @env || {} end |
#options ⇒ Object
27 28 29 |
# File 'lib/shell_mock/command_stub.rb', line 27 def @options || {} end |
#side_effect ⇒ Object
44 45 46 |
# File 'lib/shell_mock/command_stub.rb', line 44 def side_effect @side_effect || proc {} end |
#with_env(env) ⇒ Object
11 12 13 14 15 |
# File 'lib/shell_mock/command_stub.rb', line 11 def with_env(env) @env = env self end |
#with_option(option) ⇒ Object
21 22 23 24 25 |
# File 'lib/shell_mock/command_stub.rb', line 21 def with_option(option) @options = self end |