Class: Serverspec::Backend::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/serverspec/backend/base.rb

Direct Known Subclasses

Cmd, Exec, WinRM

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

Default action is to call check_zero with args



26
27
28
# File 'lib/serverspec/backend/base.rb', line 26

def method_missing(meth, *args, &block)
  check_zero(meth, *args)
end

Instance Method Details

#check_zero(cmd, *args) ⇒ Object



20
21
22
23
# File 'lib/serverspec/backend/base.rb', line 20

def check_zero(cmd, *args)
  ret = run_command(commands.send(cmd, *args))
  ret[:exit_status] == 0
end

#commandsObject



16
17
18
# File 'lib/serverspec/backend/base.rb', line 16

def commands
  @commands
end

#set_commands(c) ⇒ Object



8
9
10
# File 'lib/serverspec/backend/base.rb', line 8

def set_commands(c)
  @commands = c
end

#set_example(e) ⇒ Object



12
13
14
# File 'lib/serverspec/backend/base.rb', line 12

def set_example(e)
  @example = e
end