Skip to content

Commit

Permalink
Rearrange comments based on PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
sersut committed Mar 1, 2013
1 parent 4b880bf commit 3a70182
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 40 deletions.
15 changes: 9 additions & 6 deletions lib/chef/application/windows_service_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@

class Chef
class Application
#
# This class is used to create and manage a windows service.
# Service should be created using Daemon class from
# win32/service gem.
# For an example see: Chef::Application::WindowsService
#
# Outside programs are expected to use this class to manage
# windows services.
#
class WindowsServiceManager
#
# This class is used to create and manage a windows service.
# Service should be created using Daemon class from
# win32/service gem.
# For an example see: Chef::Application::WindowsService
#
include Mixlib::CLI

option :action,
Expand Down
71 changes: 37 additions & 34 deletions spec/functional/win32/service_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,43 @@

describe "Chef::Application::WindowsServiceManager", :windows_only do

# Some helper methods.

def test_service_exists?
::Win32::Service.exists?("spec-service")
end

def test_service_state
::Win32::Service.status("spec-service").current_state
end

def service_manager
Chef::Application::WindowsServiceManager.new(test_service)
end

def cleanup
# Uninstall if the test service is installed.
if test_service_exists?

# We can only uninstall when the service is stopped.
if test_service_state != "stopped"
::Win32::Service.send("stop", "spec-service")
while test_service_state != "stopped"
sleep 1
end
end

::Win32::Service.delete("spec-service")
end

# Delete the test_service_file if it exists
if File.exists?(test_service_file)
File.delete(test_service_file)
end

end


# Definition for the test-service

let(:test_service) {
Expand Down Expand Up @@ -227,38 +264,4 @@
end
end
end

def test_service_exists?
::Win32::Service.exists?("spec-service")
end

def test_service_state
::Win32::Service.status("spec-service").current_state
end

def service_manager
Chef::Application::WindowsServiceManager.new(test_service)
end

def cleanup
# Uninstall if the test service is installed.
if test_service_exists?

# We can only uninstall when the service is stopped.
if test_service_state != "stopped"
::Win32::Service.send("stop", "spec-service")
while test_service_state != "stopped"
sleep 1
end
end

::Win32::Service.delete("spec-service")
end

# Delete the test_service_file if it exists
if File.exists?(test_service_file)
File.delete(test_service_file)
end

end
end

0 comments on commit 3a70182

Please sign in to comment.