Class: Serverspec::Type::Service

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

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_ary, #to_s

Constructor Details

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

Instance Method Details

#enabled?(level = 3) ⇒ Boolean

Returns:

  • (Boolean)

4
5
6
# File 'lib/serverspec/type/service.rb', line 4

def enabled?(level=3)
  backend.check_enabled(@name, level)
end

#has_property?(property) ⇒ Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/serverspec/type/service.rb', line 31

def has_property?(property)
  backend.check_svcprops(@name, property)
end

#monitored_by?(monitor) ⇒ Boolean

Returns:

  • (Boolean)

22
23
24
25
26
27
28
29
# File 'lib/serverspec/type/service.rb', line 22

def monitored_by?(monitor)
  check_method = "check_monitored_by_#{monitor}".to_sym
  unless monitor && commands.respond_to?(check_method)
    raise ArgumentError.new("`be_monitored_by` matcher doesn't support #{monitor}")
  end

  backend.send(check_method, @name)
end

#running?(under) ⇒ Boolean

Returns:

  • (Boolean)

8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/serverspec/type/service.rb', line 8

def running?(under)
  if under
    check_method = "check_running_under_#{under}".to_sym

    unless commands.respond_to?(check_method)
      raise ArgumentError.new("`be_running` matcher doesn't support #{under}")
    end

    backend.send(check_method, @name)
  else
    backend.check_running(@name)
  end
end