specinfra 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0496b81232f15579c3efcce2bef98adc764fc7d
4
- data.tar.gz: 70085d506610ee34667126938d98cb84ed2606e6
3
+ metadata.gz: 5b4eed13de93f62f2bbb57ce355ea22684606c06
4
+ data.tar.gz: 14c461c8b5fc9c94761dede212cd8f67d69a60b8
5
5
  SHA512:
6
- metadata.gz: f8dca453bd2d181b32f79f0c7b6f1812bb1cc583820b0a6cf6708ff4d22dd076489e376de3be732a2d81148c920e185b843874bac21d6013bd8d6fd40e50f37a
7
- data.tar.gz: d43cc4d1909e48c10db30350298ff814e6b12c505191162ce6b79fe361599b74d8258bb537749e571d0e6c04466e5486791868d920e5c081507171c064535902
6
+ metadata.gz: 1310556dbf0eac4ea57809c3e8a9c19c8f3b6edd4d735333e6b7d63cc2f89839c359ebc49542b2bbf995dd4b3cc1137819175f29bfa23a1a7cc5f8e2d664563a
7
+ data.tar.gz: 5efff319c39a3328d342b49936c45e8b6079208e715ae279e2b3dda7ca047fa126df39c5e7abd8d702b96f1a159ed4a1a587b6a733a94c16b0bf1eeba8c82e79
@@ -7,7 +7,7 @@ module SpecInfra
7
7
 
8
8
  def run_command(cmd, opts={})
9
9
  script = create_script(cmd)
10
- result = execute_script %Q{powershell -encodedCommand #{encode_script(script)}}
10
+ result = execute_script %Q{#{powershell} -encodedCommand #{encode_script(script)}}
11
11
 
12
12
  if @example
13
13
  @example.metadata[:command] = script
@@ -34,6 +34,32 @@ module SpecInfra
34
34
  # Dirty hack for specs
35
35
  'Windows'
36
36
  end
37
+
38
+ private
39
+
40
+ def powershell
41
+ architecture = @example.metadata[:architecture] || SpecInfra.configuration.architecture
42
+
43
+ case architecture
44
+ when :i386 then x86_powershell
45
+ when :x86_64 then x64_powershell
46
+ else raise ArgumentError, "invalid architecture [#{architecture}]"
47
+ end
48
+ end
49
+
50
+ def x64_powershell
51
+ find_powershell(%w(sysnative system32))
52
+ end
53
+
54
+ def x86_powershell
55
+ find_powershell(%w(syswow64 system32))
56
+ end
57
+
58
+ def find_powershell(dirs)
59
+ dirs.map { |dir| "#{ENV['WINDIR']}\\#{dir}\\WindowsPowerShell\\v1.0\\powershell.exe" }
60
+ .find { |exe| File.exists?(exe) } || 'powershell'
61
+ end
62
+
37
63
  end
38
64
  end
39
65
  end
@@ -66,6 +66,10 @@ module SpecInfra
66
66
  end
67
67
  end
68
68
 
69
+ def get_file_content(file)
70
+ "[Io.File]::ReadAllText('#{file}')"
71
+ end
72
+
69
73
  def check_access_by_user(file, user, access)
70
74
  case access
71
75
  when 'r'
@@ -229,61 +233,61 @@ module SpecInfra
229
233
  using 'list_windows_features.ps1'
230
234
  exec cmd
231
235
  end
232
- end
236
+ end
233
237
 
234
- def check_file_version(name,version)
235
- cmd = "((Get-Command '#{name}').FileVersionInfo.ProductVersion -eq '#{version}') -or ((Get-Command '#{name}').FileVersionInfo.FileVersion -eq '#{version}')"
236
- Backend::PowerShell::Command.new { exec cmd }
237
- end
238
+ def check_file_version(name,version)
239
+ cmd = "((Get-Command '#{name}').FileVersionInfo.ProductVersion -eq '#{version}') -or ((Get-Command '#{name}').FileVersionInfo.FileVersion -eq '#{version}')"
240
+ Backend::PowerShell::Command.new { exec cmd }
241
+ end
238
242
 
239
- def check_iis_website_enabled(name)
240
- Backend::PowerShell::Command.new do
241
- using 'find_iis_component.ps1'
242
- exec "(FindIISWebsite -name '#{name}').serverAutoStart -eq $true"
243
- end
244
- end
243
+ def check_iis_website_enabled(name)
244
+ Backend::PowerShell::Command.new do
245
+ using 'find_iis_component.ps1'
246
+ exec "(FindIISWebsite -name '#{name}').serverAutoStart -eq $true"
247
+ end
248
+ end
245
249
 
246
- def check_iis_website_installed(name)
247
- Backend::PowerShell::Command.new do
248
- using 'find_iis_component.ps1'
249
- exec "@(FindIISWebsite -name '#{name}').count -gt 0"
250
- end
251
- end
250
+ def check_iis_website_installed(name)
251
+ Backend::PowerShell::Command.new do
252
+ using 'find_iis_component.ps1'
253
+ exec "@(FindIISWebsite -name '#{name}').count -gt 0"
254
+ end
255
+ end
252
256
 
253
- def check_iis_website_running(name)
254
- Backend::PowerShell::Command.new do
255
- using 'find_iis_component.ps1'
256
- exec "(FindIISWebsite -name '#{name}').state -eq 'Started'"
257
- end
258
- end
257
+ def check_iis_website_running(name)
258
+ Backend::PowerShell::Command.new do
259
+ using 'find_iis_component.ps1'
260
+ exec "(FindIISWebsite -name '#{name}').state -eq 'Started'"
261
+ end
262
+ end
259
263
 
260
- def check_iis_website_app_pool(name, app_pool)
264
+ def check_iis_website_app_pool(name, app_pool)
261
265
  Backend::PowerShell::Command.new do
262
- using 'find_iis_component.ps1'
263
- exec "(FindIISWebsite -name '#{name}').applicationPool -match '#{app_pool}'"
264
- end
266
+ using 'find_iis_component.ps1'
267
+ exec "(FindIISWebsite -name '#{name}').applicationPool -match '#{app_pool}'"
265
268
  end
269
+ end
266
270
 
267
- def check_iis_website_path(name, path)
268
- Backend::PowerShell::Command.new do
269
- using 'find_iis_component.ps1'
270
- exec "[System.Environment]::ExpandEnvironmentVariables( ( FindIISWebsite -name '#{name}' ).physicalPath ).replace('\\', '/' ) -eq ('#{path}'.trimEnd('/').replace('\\', '/'))"
271
- end
271
+ def check_iis_website_path(name, path)
272
+ Backend::PowerShell::Command.new do
273
+ using 'find_iis_component.ps1'
274
+ exec "[System.Environment]::ExpandEnvironmentVariables( ( FindIISWebsite -name '#{name}' ).physicalPath ).replace('\\', '/' ) -eq ('#{path}'.trimEnd('/').replace('\\', '/'))"
272
275
  end
276
+ end
273
277
 
274
- def check_iis_app_pool(name)
275
- Backend::PowerShell::Command.new do
276
- using 'find_iis_component.ps1'
277
- exec "@(FindIISAppPool -name '#{name}').count -gt 0"
278
- end
278
+ def check_iis_app_pool(name)
279
+ Backend::PowerShell::Command.new do
280
+ using 'find_iis_component.ps1'
281
+ exec "@(FindIISAppPool -name '#{name}').count -gt 0"
279
282
  end
283
+ end
280
284
 
281
- def check_iis_app_pool_dotnet(name, dotnet)
282
- Backend::PowerShell::Command.new do
283
- using 'find_iis_component.ps1'
284
- exec "(FindIISAppPool -name '#{name}').managedRuntimeVersion -match 'v#{dotnet}'"
285
- end
285
+ def check_iis_app_pool_dotnet(name, dotnet)
286
+ Backend::PowerShell::Command.new do
287
+ using 'find_iis_component.ps1'
288
+ exec "(FindIISAppPool -name '#{name}').managedRuntimeVersion -match 'v#{dotnet}'"
286
289
  end
290
+ end
287
291
 
288
292
  private
289
293
 
@@ -1,3 +1,3 @@
1
1
  module SpecInfra
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/specinfra.rb CHANGED
@@ -24,6 +24,7 @@ if defined?(RSpec)
24
24
  c.add_setting :scp, :default => nil
25
25
  c.add_setting :sudo_password, :default => nil
26
26
  c.add_setting :winrm, :default => nil
27
+ c.add_setting :architecture, :default => :x86_64
27
28
  SpecInfra.configuration.defaults.each { |k, v| c.add_setting k, :default => v }
28
29
  c.before :each do
29
30
  if respond_to?(:backend) && backend.respond_to?(:set_example)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler