Class: Serverspec::Type::Service

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

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Service

Returns a new instance of Service.



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

def initialize name
  @name = name
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/serverspec/type/service.rb', line 8

def enabled?
  backend.check_enabled(nil, @name)
end

#running?(under) ⇒ Boolean

Returns:

  • (Boolean)


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

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

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

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

#to_sObject



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

def to_s
  "Service #{@name}"
end