summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2013-03-01 14:54:16 -0800
committersersut <serdar@opscode.com>2013-03-01 14:54:52 -0800
commit3a70182d28ffadfa07c8a54b8555e9a2137f53c4 (patch)
tree1bc834e60ff623bb298026a5340b9872a97c6530
parent4b880bfe6d916b8ca844c72f7ab9f30a8b2b9f0d (diff)
downloadchef-3a70182d28ffadfa07c8a54b8555e9a2137f53c4.tar.gz
Rearrange comments based on PR feedback.
-rw-r--r--lib/chef/application/windows_service_manager.rb15
-rw-r--r--spec/functional/win32/service_manager_spec.rb71
2 files changed, 46 insertions, 40 deletions
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index 27e21a1acb..13bd2c5cd6 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -22,13 +22,16 @@ require 'mixlib/cli'
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,
diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb
index 439c87478b..b15d1061b9 100644
--- a/spec/functional/win32/service_manager_spec.rb
+++ b/spec/functional/win32/service_manager_spec.rb
@@ -33,6 +33,43 @@ require 'chef/application/windows_service_manager'
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) {
@@ -227,38 +264,4 @@ describe "Chef::Application::WindowsServiceManager", :windows_only do
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