Test-Kitchen серверная спецификация тестирования исключения для Windows
Когда используешь chef generate cookbook hello
команда, серверная спецификация spec_helper.rb
сгенерированный файл не будет работать с Test-Kitchen 1.4.1 и windows.
kitchen verify
Команда выдаст следующее на платформе Windows:
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)
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:98:in `spawn_command'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:13:in `block in run_command'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:133:in `with_env'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/backend/exec.rb:12:in `run_command'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/detect_os.rb:13:in `run_command'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/detect_os/arch.rb:3:in `detect'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/detect_os.rb:5:in `detect'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:24:in `block in detect_os'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:23:in `each'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:23:in `detect_os'
from C:/Users/vagrant/AppData/Local/Temp/verifier/gems/gems/specinfra-2.37.5/lib/specinfra/helper/os.rb:9:in `os'
from C:/Users/vagrant/AppData/Local/Temp/verifier/suites/serverspec/windows_spec.rb:4:in `<top (required)>'
1 ответ
Решение
Смена тест-кухни spec_helper.rb
файл для тестирования окон и настройки бэкенда и ОС соответственно исправляет проблему:
require 'serverspec'
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
set :backend, :exec
else
set :backend, :cmd
set :os, family: 'windows'
end
Затем вы можете протестировать на разных платформах, например:
require 'spec_helper'
case os[:family]
when 'windows'
describe file('C:\Users\vagrant\foo.txt') do
it { should be_file }
end
when 'darwin' # mac os x
describe file('/user/vagrant/foo.txt') do
it { should be_file }
end
when 'ubuntu'
describe file('/home/vagrant/foo.txt') do
it { should be_file }
end
end