summaryrefslogtreecommitdiff
path: root/kitchen-tests/test/fixtures/serverspec_helper.rb
blob: feb4c212002c3d9147e22bab3303cf0aaeba3104 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Shamelessly copied from https://github.com/onehealth-cookbooks/apache2/blob/master/test/fixtures/serverspec_helper.rb
# The commented-out platforms in the osmapping hash can be added once we have added them into
# our .kitchen.yml and .kitchen.travis.yml and added the appropriate JSON under test/fixtures/platforms.

require "serverspec"
require "json"
require "ffi_yajl"

set :backend, :exec

include Specinfra::Helper::Properties

require "pp"
pp os

def load_nodestub
  case os[:family]
  when "ubuntu", "debian"
    platform = os[:family]
    platform_version = os[:release]
  when "redhat"
    platform = "centos"
    platform_version = os[:release].to_i
  end
  FFI_Yajl::Parser.parse(IO.read("#{ENV['BUSSER_ROOT']}/../kitchen/data/platforms/#{platform}/#{platform_version}.json"), :symbolize_names => true)
end

# centos-59 doesn't have /sbin in the default path,
# so we must ensure it's on serverspec's path
set :path, "$PATH:/sbin"

set_property load_nodestub