lib/kitchen/verifier/pester.rb in kitchen-pester-0.2.3 vs lib/kitchen/verifier/pester.rb in kitchen-pester-0.3.0

- old
+ new

@@ -27,10 +27,12 @@ kitchen_verifier_api_version 1 plugin_version Kitchen::Verifier::PESTER_VERSION + default_config :restart_winrm, false + # Creates a new Verifier object using the provided configuration data # which will be merged with any default configuration. # # @param config [Hash] provided verifier configuration def initialize(config = {}) @@ -67,10 +69,11 @@ # @return [String] a command string def install_command return if local_suite_files.empty? cmd = <<-CMD + set-executionpolicy unrestricted -force if (-not (get-module -list pester)) { if (-not (get-module PsGet)){ iex (new-object Net.WebClient).DownloadString('http://bit.ly/GetPsGet') } Import-Module PsGet @@ -85,10 +88,11 @@ # but before the sandbox has been transferred to the instance. If no work # is required, then `nil` will be returned. # # @return [String] a command string def init_command + restart_winrm_service if config[:restart_winrm] end # Generates a command string which will perform any commands or # configuration required just before the main verifier run command but # after the sandbox has been transferred to the instance. If no work is @@ -103,18 +107,26 @@ # will be returned. # # @return [String] a command string def run_command return if local_suite_files.empty? - - wrap_shell_code(Util.outdent!(<<-CMD)) + wrap_shell_code(Util.outdent!(<<-CMD cd "#{File.join(config[:root_path],'suites/pester/' )}" $global:ProgressPreference = 'SilentlyContinue' - invoke-pester -enableexit + import-module Pester -force; invoke-pester -enableexit CMD + )) end #private + + def restart_winrm_service + wrap_shell_code(Util.outdent!(<<-CMD + schtasks /Create /TN restart_winrm /TR "powershell -command restart-service winrm" /SC ONCE /ST 00:00 + schtasks /RUN /TN restart_winrm + CMD + )) + end # Returns an Array of test suite filenames for the related suite currently # residing on the local workstation. Any special provisioner-specific # directories (such as a Chef roles/ directory) are excluded. # \ No newline at end of file