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

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

#envObject (readonly)

Returns the value of attribute env.



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

def env
  @env
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

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

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

#callsObject



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

  self
end