chef - Test-Kitchen serverspec testing exception on windows -


when using chef generate cookbook hello command, serverspec spec_helper.rb file generated not work test-kitchen 1.4.1 , windows.

kitchen verify command throw following on windows platform:

c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:98:in `spawn': no such file or directory - /bin/sh -c ls\ /etc/arch-release (errno::enoent)     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:98:in `spawn_command'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:13:in `block in run_command'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:133:in `with_env'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:12:in `run_command'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/detect_os.rb:13:in `run_command'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/detect_os/arch.rb:3:in `detect'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/detect_os.rb:5:in `detect'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:24:in `block in detect_os'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:23:in `each'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:23:in `detect_os'     c:/users/vagrant/appdata/local/temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:9:in `os'     c:/users/vagrant/appdata/local/temp/verifier/suites/serverspec/windows_spec.rb:4:in `<top (required)>' 

changing test-kitchen spec_helper.rb file test windows , setting backend , os accordingly, fixes issue:

require 'serverspec'  if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ ruby_platform).nil?   set :backend, :exec else   set :backend, :cmd   set :os, family: 'windows' end 

you can test against different platforms, example:

require 'spec_helper'  case os[:family] when 'windows'   describe file('c:\users\vagrant\foo.txt')     { should be_file }   end when 'darwin' # mac os x   describe file('/user/vagrant/foo.txt')     { should be_file }   end when 'ubuntu'   describe file('/home/vagrant/foo.txt')     { should be_file }   end end 

Comments