Class: ShellMock::CommandStub

Inherits:
Object
  • Object
show all
Defined in:
lib/shell_mock/command_stub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/shell_mock/command_stub.rb', line 5

def command
  @command
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



5
6
7
# File 'lib/shell_mock/command_stub.rb', line 5

def exitstatus
  @exitstatus
end

#expected_outputObject (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, options)
  calls << [env, command, options]
end

#callsObject



48
49
50
# File 'lib/shell_mock/command_stub.rb', line 48

def calls
  @calls ||= []
end

#envObject



17
18
19
# File 'lib/shell_mock/command_stub.rb', line 17

def env
  @env || {}
end

#optionsObject



27
28
29
# File 'lib/shell_mock/command_stub.rb', line 27

def options
  @options || {}
end

#side_effectObject



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 = options

  self
end