Sha256: 0fe0e53ac2a8e8842957f812132aa11fde972c4885b5e1ccca3407758bdbf70e

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

Contents

RSpec::Matchers.define :run_under_account do |account_name|
  match do |service|
    @runner = Specinfra::Runner
    command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName -eq '#{account_name}'")
    command_result.stdout.strip == 'True'
  end

  failure_message do |service|
    command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName")
    "Expected service '#{service.name}' to be running under '#{account_name}' but was running under '#{command_result.stdout.strip}'"
  end

  failure_message_when_negated do |service|
    command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName")
    "Expected service '#{service.name}' to not be running under '#{account_name}' but was running under '#{command_result.stdout.strip}'"
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
octopus-serverspec-extensions-0.18.1 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.18.0 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.17.3 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.17.2 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.17.1 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.17.0 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.15.5 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.15.4 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.15.3 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.15.2 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.15.1 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.15.0 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.13.6 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.13.5 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.13.4 lib/octopus_serverspec_extensions/matcher/run_under_account.rb
octopus-serverspec-extensions-0.13.3 lib/octopus_serverspec_extensions/matcher/run_under_account.rb