diff --git a/resources/install.rb b/resources/install.rb index ab36f5c..69a522e 100755 --- a/resources/install.rb +++ b/resources/install.rb @@ -79,10 +79,12 @@ source package_file action :unzip not_if { ::File.exist?(new_resource.conf_dir + '/install-service-filebeat.ps1') } + notifies :run, 'powershell_script[install filebeat as service]', :immediately end powershell_script 'install filebeat as service' do code "& '#{new_resource.conf_dir}/install-service-filebeat.ps1'" + action :nothing end end diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb index a841bac..db9510e 100644 --- a/spec/unit/recipes/default_spec.rb +++ b/spec/unit/recipes/default_spec.rb @@ -99,7 +99,8 @@ end it 'run powershell_script to install filebeat as service' do - expect(chef_run).to run_powershell_script('install filebeat as service') + expect(chef_run.windows_zipfile('C:/opt/filebeat')).to notify('powershell_script[install filebeat as service]').to(:run).immediately + expect(chef_run).to_not run_powershell_script('install filebeat as service') end end