Class: Serverspec::Type::Command

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/command.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_s

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Instance Method Details

#return_exit_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/serverspec/type/command.rb', line 25

def return_exit_status?(status)
  ret = backend.run_command(@name)
  ret[:exit_status].to_i == status
end

#return_stderr?(content) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/serverspec/type/command.rb', line 13

def return_stderr?(content)
  ret = backend.run_command(@name)
  # In ssh access with pty, stderr is merged to stdout
  # See http://stackoverflow.com/questions/7937651/receiving-extended-data-with-ssh-using-twisted-conch-as-client
  # So I use stdout instead of stderr
  if content.instance_of?(Regexp)
    ret[:stdout] =~ content
  else
    ret[:stdout].strip == content
  end
end

#return_stdout?(content) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
# File 'lib/serverspec/type/command.rb', line 4

def return_stdout?(content)
  ret = backend.run_command(@name)
  if content.instance_of?(Regexp)
    ret[:stdout] =~ content
  else
    ret[:stdout].strip == content
  end
end