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.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#exitstatus ⇒ Object
readonly
Returns the value of attribute exitstatus.
-
#expected_output ⇒ Object
readonly
Returns the value of attribute expected_output.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#side_effect ⇒ Object
readonly
Returns the value of attribute side_effect.
Instance Method Summary collapse
- #and_exit(exitstatus) ⇒ Object
- #and_return(expected_output) ⇒ Object
- #called_with(env, command, options) ⇒ Object
- #calls ⇒ Object
-
#initialize(command) ⇒ CommandStub
constructor
A new instance of CommandStub.
- #with_env(env) ⇒ Object
- #with_option(option) ⇒ Object
Constructor Details
#initialize(command) ⇒ CommandStub
Returns a new instance of CommandStub.
7 8 9 10 11 12 13 |
# File 'lib/shell_mock/command_stub.rb', line 7 def initialize(command) @command = command @env = {} @options = {} @side_effect = proc {} @exitstatus = 0 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 |
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/shell_mock/command_stub.rb', line 5 def env @env 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 |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/shell_mock/command_stub.rb', line 5 def @options end |
#side_effect ⇒ Object (readonly)
Returns the value of attribute side_effect.
5 6 7 |
# File 'lib/shell_mock/command_stub.rb', line 5 def side_effect @side_effect end |
Instance Method Details
#and_exit(exitstatus) ⇒ Object
34 35 36 37 38 |
# File 'lib/shell_mock/command_stub.rb', line 34 def and_exit(exitstatus) @exitstatus = exitstatus self end |
#and_return(expected_output) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/shell_mock/command_stub.rb', line 27 def and_return(expected_output) @expected_output = expected_output @exitstatus = 0 self end |
#called_with(env, command, options) ⇒ Object
44 45 46 |
# File 'lib/shell_mock/command_stub.rb', line 44 def called_with(env, command, ) calls << [env, command, ] end |
#calls ⇒ Object
40 41 42 |
# File 'lib/shell_mock/command_stub.rb', line 40 def calls @calls ||= [] end |
#with_env(env) ⇒ Object
15 16 17 18 19 |
# File 'lib/shell_mock/command_stub.rb', line 15 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 |