omnibus 3.1.1 → 3.2.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/Gemfile +0 -7
  4. data/README.md +108 -36
  5. data/Rakefile +1 -5
  6. data/docs/omnibus-build-cache.md +5 -5
  7. data/features/commands/_deprecated.feature +21 -3
  8. data/features/step_definitions/generator_steps.rb +7 -7
  9. data/lib/omnibus.rb +232 -171
  10. data/lib/omnibus/build_version.rb +2 -2
  11. data/lib/omnibus/builder.rb +38 -19
  12. data/lib/omnibus/cleaner.rb +5 -5
  13. data/lib/omnibus/cleanroom.rb +141 -0
  14. data/lib/omnibus/cli.rb +6 -9
  15. data/lib/omnibus/cli/base.rb +2 -1
  16. data/lib/omnibus/cli/cache.rb +15 -21
  17. data/lib/omnibus/cli/deprecated.rb +40 -4
  18. data/lib/omnibus/cli/publish.rb +61 -0
  19. data/lib/omnibus/config.rb +350 -189
  20. data/lib/omnibus/digestable.rb +131 -0
  21. data/lib/omnibus/exceptions.rb +163 -83
  22. data/lib/omnibus/fetcher.rb +1 -1
  23. data/lib/omnibus/fetchers/net_fetcher.rb +19 -13
  24. data/lib/omnibus/fetchers/path_fetcher.rb +8 -1
  25. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +16 -7
  26. data/lib/omnibus/generator.rb +2 -2
  27. data/lib/omnibus/generator_files/Gemfile.erb +4 -1
  28. data/lib/omnibus/generator_files/README.md.erb +10 -0
  29. data/lib/omnibus/generator_files/{omnibus.rb.example.erb → omnibus.rb.erb} +20 -11
  30. data/lib/omnibus/generator_files/package_scripts/makeselfinst.erb +1 -1
  31. data/lib/omnibus/generator_files/project.rb.erb +2 -2
  32. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +3 -3
  33. data/lib/omnibus/git_cache.rb +192 -0
  34. data/lib/omnibus/health_check.rb +171 -116
  35. data/lib/omnibus/library.rb +4 -2
  36. data/lib/omnibus/logger.rb +60 -1
  37. data/lib/omnibus/null_argumentable.rb +51 -0
  38. data/lib/omnibus/ohai.rb +29 -8
  39. data/lib/omnibus/package.rb +240 -0
  40. data/lib/omnibus/packagers/base.rb +21 -42
  41. data/lib/omnibus/packagers/mac_dmg.rb +5 -5
  42. data/lib/omnibus/packagers/mac_pkg.rb +20 -19
  43. data/lib/omnibus/packagers/windows_msi.rb +7 -7
  44. data/lib/omnibus/project.rb +969 -486
  45. data/lib/omnibus/publisher.rb +76 -0
  46. data/lib/omnibus/publishers/artifactory_publisher.rb +168 -0
  47. data/lib/omnibus/publishers/null_publisher.rb +23 -0
  48. data/lib/omnibus/publishers/s3_publisher.rb +99 -0
  49. data/lib/omnibus/s3_cache.rb +150 -63
  50. data/lib/omnibus/software.rb +749 -321
  51. data/lib/omnibus/{sugar.rb → sugarable.rb} +11 -6
  52. data/lib/omnibus/version.rb +1 -1
  53. data/omnibus.gemspec +8 -8
  54. data/spec/data/complicated/config/projects/angrychef.rb +1 -1
  55. data/spec/data/complicated/config/projects/chef-windows.rb +1 -1
  56. data/spec/data/complicated/config/projects/chef.rb +1 -1
  57. data/spec/data/complicated/config/projects/chefdk-windows.rb +1 -1
  58. data/spec/data/complicated/config/projects/chefdk.rb +1 -1
  59. data/spec/data/complicated/config/software/cacerts.rb +1 -1
  60. data/spec/data/complicated/config/software/chef-client-msi.rb +1 -1
  61. data/spec/data/complicated/config/software/libgcc.rb +1 -1
  62. data/spec/data/complicated/config/software/libiconv.rb +0 -11
  63. data/spec/data/complicated/config/software/libpng.rb +2 -2
  64. data/spec/data/complicated/config/software/openssl.rb +1 -1
  65. data/spec/data/complicated/config/software/ruby.rb +1 -1
  66. data/spec/data/complicated/config/software/runit.rb +4 -4
  67. data/spec/data/projects/chefdk.rb +1 -1
  68. data/spec/data/projects/sample.rb +1 -1
  69. data/spec/data/software/erchef.rb +3 -1
  70. data/spec/functional/packagers/mac_spec.rb +25 -24
  71. data/spec/functional/packagers/windows_spec.rb +21 -20
  72. data/spec/spec_helper.rb +43 -4
  73. data/spec/unit/build_version_spec.rb +14 -16
  74. data/spec/unit/cleanroom_spec.rb +63 -0
  75. data/spec/unit/config_spec.rb +36 -30
  76. data/spec/unit/digestable_spec.rb +38 -0
  77. data/spec/unit/fetchers/net_fetcher_spec.rb +98 -87
  78. data/spec/unit/{install_path_cache_spec.rb → git_cache_spec.rb} +67 -56
  79. data/spec/unit/health_check_spec.rb +73 -0
  80. data/spec/unit/library_spec.rb +166 -159
  81. data/spec/unit/ohai_spec.rb +19 -0
  82. data/spec/unit/omnibus_spec.rb +43 -41
  83. data/spec/unit/package_spec.rb +178 -0
  84. data/spec/unit/packagers/base_spec.rb +17 -47
  85. data/spec/unit/packagers/mac_pkg_spec.rb +104 -126
  86. data/spec/unit/project_spec.rb +176 -25
  87. data/spec/unit/publisher_spec.rb +49 -0
  88. data/spec/unit/publishers/artifactory_publisher_spec.rb +80 -0
  89. data/spec/unit/publishers/s3_publisher_spec.rb +120 -0
  90. data/spec/unit/s3_cacher_spec.rb +84 -19
  91. data/spec/unit/software_spec.rb +397 -170
  92. data/spec/unit/sugarable_spec.rb +43 -0
  93. metadata +62 -50
  94. data/Guardfile +0 -10
  95. data/lib/omnibus/artifact.rb +0 -165
  96. data/lib/omnibus/cli/release.rb +0 -40
  97. data/lib/omnibus/generator_files/Vagrantfile.erb +0 -75
  98. data/lib/omnibus/install_path_cache.rb +0 -105
  99. data/lib/omnibus/overrides.rb +0 -88
  100. data/lib/omnibus/package_release.rb +0 -154
  101. data/lib/omnibus/software_s3_urls.rb +0 -50
  102. data/spec/unit/artifact_spec.rb +0 -91
  103. data/spec/unit/overrides_spec.rb +0 -102
  104. data/spec/unit/package_release_spec.rb +0 -180
  105. data/spec/unit/sugar_spec.rb +0 -17
@@ -29,8 +29,17 @@ require 'chef/sugar/shell'
29
29
  require 'chef/sugar/vagrant'
30
30
 
31
31
  module Omnibus
32
- class Project
33
- private
32
+ module Sugarable
33
+ def self.included(base)
34
+ base.send(:include, Chef::Sugar::DSL)
35
+
36
+ if base < Cleanroom
37
+ # Make all the "sugars" available in the cleanroom (DSL)
38
+ Chef::Sugar::DSL.instance_methods.each do |instance_method|
39
+ base.send(:expose, instance_method)
40
+ end
41
+ end
42
+ end
34
43
 
35
44
  # This method is used by Chef Sugar to easily add the DSL. By mimicing
36
45
  # Chef's +node+ object, we can easily include the existing DSL into
@@ -41,7 +50,3 @@ module Omnibus
41
50
  end
42
51
  end
43
52
  end
44
-
45
- # Include everything in Omnibus
46
- Omnibus::Project.send(:include, Chef::Sugar::DSL)
47
- Omnibus::Software.send(:include, Chef::Sugar::DSL)
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Omnibus
18
- VERSION = '3.1.1'
18
+ VERSION = '3.2.0.rc.1'
19
19
  end
@@ -22,17 +22,17 @@ Gem::Specification.new do |gem|
22
22
  gem.require_paths = ['lib']
23
23
 
24
24
  gem.add_dependency 'chef-sugar', '~> 1.2'
25
- gem.add_dependency 'mixlib-shellout', '~> 1.3'
26
- gem.add_dependency 'mixlib-config', '~> 2.1'
27
- gem.add_dependency 'ohai', '~> 6.12'
28
- gem.add_dependency 'fpm', '~> 1.0.0'
25
+ gem.add_dependency 'mixlib-shellout', '~> 1.4'
26
+ gem.add_dependency 'ohai', '~> 7.2.0.rc'
27
+ gem.add_dependency 'fpm', '~> 0.4'
29
28
  gem.add_dependency 'uber-s3'
30
29
  gem.add_dependency 'thor', '~> 0.18'
31
30
 
32
- gem.add_development_dependency 'aruba', '~> 0.5'
33
- gem.add_development_dependency 'fauxhai', '~> 2.1'
34
- gem.add_development_dependency 'rspec', '~> 2.14'
35
- gem.add_development_dependency 'rubocop', '0.21.0'
31
+ gem.add_development_dependency 'artifactory', '~> 1.2'
32
+ gem.add_development_dependency 'aruba', '~> 0.5'
33
+ gem.add_development_dependency 'fauxhai', '~> 2.1'
34
+ gem.add_development_dependency 'rspec', '~> 2.14'
35
+ gem.add_development_dependency 'rspec-its'
36
36
  gem.add_development_dependency 'rake'
37
37
 
38
38
  gem.add_development_dependency 'bundler'
@@ -23,7 +23,7 @@ maintainer "Opscode, Inc."
23
23
  homepage "http://www.opscode.com"
24
24
 
25
25
  replaces "angrychef"
26
- install_path "/opt/angrychef"
26
+ install_dir "/opt/angrychef"
27
27
  build_version '1.0.0'
28
28
  build_iteration 4
29
29
 
@@ -22,7 +22,7 @@ homepage "http://www.opscode.com"
22
22
  # NOTE: Ruby DevKit fundamentally CANNOT be installed into "Program Files"
23
23
  # Native gems will use gcc which will barf on files with spaces,
24
24
  # which is only fixable if everyone in the world fixes their Makefiles
25
- install_path "c:\\opscode\\chef"
25
+ install_dir "c:\\opscode\\chef"
26
26
  build_version '1.0.0'
27
27
  build_iteration 4
28
28
  package_name "chef-client"
@@ -21,7 +21,7 @@ maintainer "Opscode, Inc."
21
21
  homepage "http://www.opscode.com"
22
22
 
23
23
  replaces "chef-full"
24
- install_path "/opt/chef"
24
+ install_dir "/opt/chef"
25
25
  build_version '1.0.0'
26
26
  build_iteration 4
27
27
  mac_pkg_identifier "com.getchef.pkg.chef"
@@ -22,7 +22,7 @@ homepage "http://www.opscode.com"
22
22
  # NOTE: Ruby DevKit fundamentally CANNOT be installed into "Program Files"
23
23
  # Native gems will use gcc which will barf on files with spaces,
24
24
  # which is only fixable if everyone in the world fixes their Makefiles
25
- install_path "c:\\opscode\\chefdk"
25
+ install_dir "c:\\opscode\\chefdk"
26
26
  build_version '1.0.0'
27
27
  build_iteration 1
28
28
 
@@ -20,7 +20,7 @@ friendly_name "Chef DK"
20
20
  maintainer "Opscode, Inc."
21
21
  homepage "http://www.opscode.com"
22
22
 
23
- install_path "/opt/chefdk"
23
+ install_dir "/opt/chefdk"
24
24
  build_version '1.0.0'
25
25
  build_iteration 1
26
26
  mac_pkg_identifier "com.getchef.pkg.chefdk"
@@ -34,7 +34,7 @@ build do
34
34
  # fix worked. Rather than trying to fix this now, we're filing a bug and copying the cacert.pem
35
35
  # directly from the cache instead.
36
36
 
37
- FileUtils.cp(File.expand_path("cacert.pem", Omnibus.config.cache_dir),
37
+ FileUtils.cp(File.expand_path("cacert.pem", Config.cache_dir),
38
38
  File.expand_path("embedded/ssl/certs/cacert.pem", install_dir))
39
39
  end
40
40
 
@@ -17,7 +17,7 @@
17
17
 
18
18
  name "chef-client-msi"
19
19
 
20
- source :path => File.expand_path("files/msi", Omnibus.project_root)
20
+ source :path => File.expand_path("files/msi", Config.project_root)
21
21
 
22
22
  build do
23
23
  # harvest with heat.exe
@@ -18,7 +18,7 @@
18
18
  name "libgcc"
19
19
  description "On UNIX systems where we bootstrap a compiler, copy the libgcc"
20
20
 
21
- if (platform == "solaris2" && Omnibus.config.solaris_compiler == "gcc")
21
+ if (platform == "solaris2" && Config.solaris_compiler == "gcc")
22
22
  build do
23
23
  if File.exists?("/opt/csw/lib/libgcc_s.so.1")
24
24
  command "cp /opt/csw/lib/libgcc_s.so.1 #{install_dir}/embedded/lib/"
@@ -48,18 +48,7 @@ if platform == "solaris2"
48
48
  env.merge!({"LDFLAGS" => "-R#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include -static-libgcc", "LD_OPTIONS" => "-R#{install_dir}/embedded/lib"})
49
49
  end
50
50
 
51
- def glibc_dropped_gets?
52
- return false unless Ohai["os"] == "linux"
53
-
54
- output = `/usr/bin/env getconf GNU_LIBC_VERSION`
55
-
56
- return false unless output =~ /^glibc/
57
-
58
- output.sub(/glibc /, "").to_f >= 2.16
59
- end
60
-
61
51
  build do
62
- patch :source => 'libiconv-1.14_srclib_stdio.in.h-remove-gets-declarations.patch' if glibc_dropped_gets?
63
52
  command "./configure --prefix=#{install_dir}/embedded", :env => env
64
53
  command "make -j #{max_build_jobs}", :env => env
65
54
  command "make -j #{max_build_jobs} install-lib libdir=#{install_dir}/embedded/lib includedir=#{install_dir}/embedded/include", :env => env
@@ -16,12 +16,12 @@
16
16
  #
17
17
 
18
18
  name "libpng"
19
- default_version "1.5.17"
19
+ default_version "1.5.18"
20
20
 
21
21
  dependency "zlib"
22
22
 
23
23
  source :url => "ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng15/libpng-#{version}.tar.gz",
24
- :md5 => "d2e27dbd8c6579d1582b3f128fd284b4"
24
+ :md5 => "5266905cef49d1224437465ad4d67fd9"
25
25
 
26
26
  relative_path "libpng-#{version}"
27
27
 
@@ -105,7 +105,7 @@ build do
105
105
  "-R#{install_dir}/embedded/lib",
106
106
  "-static-libgcc"].join(" ")
107
107
  when "solaris2"
108
- if Omnibus.config.solaris_compiler == "gcc"
108
+ if Config.solaris_compiler == "gcc"
109
109
  if architecture == "sparc"
110
110
  ["/bin/sh ./Configure",
111
111
  "solaris-sparcv9-gcc",
@@ -25,7 +25,7 @@ dependency "openssl"
25
25
  dependency "libyaml"
26
26
  dependency "libiconv"
27
27
  dependency "gdbm"
28
- dependency "libgcc" if (platform == "solaris2" and Omnibus.config.solaris_compiler == "gcc")
28
+ dependency "libgcc" if (platform == "solaris2" and Config.solaris_compiler == "gcc")
29
29
 
30
30
  version "1.9.3-p484" do
31
31
  source md5: '8ac0dee72fe12d75c8b2d0ef5d0c2968'
@@ -27,7 +27,7 @@ working_dir = "#{project_dir}/runit-2.1.1"
27
27
 
28
28
  build do
29
29
  # put runit where we want it, not where they tell us to
30
- command 'sed -i -e "s/^char\ \*varservice\ \=\"\/service\/\";$/char\ \*varservice\ \=\"' + project.install_path.gsub("/", "\\/") + '\/service\/\";/" src/sv.c', :cwd => working_dir
30
+ command 'sed -i -e "s/^char\ \*varservice\ \=\"\/service\/\";$/char\ \*varservice\ \=\"' + project.install_dir.gsub("/", "\\/") + '\/service\/\";/" src/sv.c', :cwd => working_dir
31
31
  # TODO: the following is not idempotent
32
32
  command "sed -i -e s:-static:: src/Makefile", :cwd => working_dir
33
33
 
@@ -50,7 +50,7 @@ build do
50
50
  end
51
51
 
52
52
  block do
53
- install_path = self.project.install_path
53
+ install_dir = self.project.install_dir
54
54
  open("#{install_dir}/embedded/bin/runsvdir-start", "w") do |file|
55
55
  file.print <<-EOH
56
56
  #!/bin/bash
@@ -71,7 +71,7 @@ build do
71
71
  # limitations under the License.
72
72
  #
73
73
 
74
- PATH=#{install_path}/bin:#{install_path}/embedded/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
74
+ PATH=#{install_dir}/bin:#{install_dir}/embedded/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
75
75
 
76
76
  # enforce our own ulimits
77
77
 
@@ -98,7 +98,7 @@ echo "1000000" > /proc/sys/fs/file-max
98
98
  umask 022
99
99
 
100
100
  exec env - PATH=$PATH \
101
- runsvdir -P #{install_path}/service 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
101
+ runsvdir -P #{install_dir}/service 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
102
102
  EOH
103
103
  end
104
104
  end
@@ -19,7 +19,7 @@ name 'chefdk'
19
19
  maintainer 'Chef Software, Inc.'
20
20
  homepage 'http://www.getchef.com'
21
21
 
22
- install_path '/opt/chefdk'
22
+ install_dir '/opt/chefdk'
23
23
  build_version Omnibus::BuildVersion.new.git_describe
24
24
  build_iteration 4
25
25
 
@@ -1,5 +1,5 @@
1
1
  name 'sample'
2
- install_path '/sample'
2
+ install_dir '/sample'
3
3
  maintainer 'Sample Devs'
4
4
  homepage 'http://example.com/'
5
5
 
@@ -18,7 +18,9 @@
18
18
  name 'erchef'
19
19
  default_version '4b19a96d57bff9bbf4764d7323b92a0944009b9e'
20
20
 
21
- dependencies %w(erlang rsync curl)
21
+ dependency 'erlang'
22
+ dependency 'rsync'
23
+ dependency 'curl'
22
24
 
23
25
  source git: 'git://github.com/opscode/erchef'
24
26
 
@@ -6,39 +6,40 @@ module Omnibus
6
6
  let(:version) { '12.4.0' }
7
7
 
8
8
  let(:project) do
9
- Project.new(<<-EOH, __FILE__)
10
- name '#{name}'
11
- maintainer 'Chef'
12
- homepage 'https://getchef.com'
13
- build_version '#{version}'
14
- install_path '#{tmp_path}/opt/#{name}'
15
- mac_pkg_identifier 'test.pkg.#{name}'
16
- EOH
9
+ allow(IO).to receive(:read)
10
+ .with('/project.rb')
11
+ .and_return <<-EOH.gsub(/^ {10}/, '')
12
+ name '#{name}'
13
+ maintainer 'Chef'
14
+ homepage 'https://getchef.com'
15
+ build_version '#{version}'
16
+ install_dir '#{tmp_path}/opt/#{name}'
17
+ mac_pkg_identifier 'test.pkg.#{name}'
18
+ EOH
19
+
20
+ Project.load('/project.rb')
17
21
  end
18
22
 
19
23
  let(:mac_packager) { Packager::MacPkg.new(project) }
20
24
 
21
25
  before do
22
- # Reset stale configuration
23
- Omnibus.config.reset!
24
-
25
26
  # Tell things to install into the cache directory
26
27
  root = "#{tmp_path}/var/omnibus"
27
- Omnibus.config.cache_dir "#{root}/cache"
28
- Omnibus.config.install_path_cache_dir "#{root}/cache/install_path"
29
- Omnibus.config.source_dir "#{root}/src"
30
- Omnibus.config.build_dir "#{root}/build"
31
- Omnibus.config.package_dir "#{root}/pkg"
32
- Omnibus.config.package_tmp "#{root}/pkg-tmp"
28
+ Config.cache_dir "#{root}/cache"
29
+ Config.git_cache_dir "#{root}/cache/git_cache"
30
+ Config.source_dir "#{root}/src"
31
+ Config.build_dir "#{root}/build"
32
+ Config.package_dir "#{root}/pkg"
33
+ Config.package_tmp "#{root}/pkg-tmp"
33
34
 
34
35
  # Enable DMG create
35
- Omnibus.config.build_dmg true
36
+ Config.build_dmg true
36
37
 
37
38
  # Point at our sample project fixture
38
- Omnibus.config.project_root "#{fixtures_path}/sample"
39
+ Config.project_root "#{fixtures_path}/sample"
39
40
 
40
41
  # Create the target directory
41
- FileUtils.mkdir_p(project.install_path)
42
+ FileUtils.mkdir_p(project.install_dir)
42
43
  end
43
44
 
44
45
  it 'builds a pkg and a dmg' do
@@ -47,11 +48,11 @@ module Omnibus
47
48
 
48
49
  # There is a tiny bit of hard-coding here, but I don't see a better
49
50
  # solution for generating the package name
50
- pkg = "#{project.package_dir}/#{name}-#{version}-1.pkg"
51
- dmg = "#{project.package_dir}/#{name}-#{version}-1.dmg"
51
+ pkg = "#{Config.package_dir}/#{name}-#{version}-1.pkg"
52
+ dmg = "#{Config.package_dir}/#{name}-#{version}-1.dmg"
52
53
 
53
- expect(File.exist?(pkg)).to be_true
54
- expect(File.exist?(dmg)).to be_true
54
+ expect(File.exist?(pkg)).to be_truthy
55
+ expect(File.exist?(dmg)).to be_truthy
55
56
  end
56
57
  end
57
58
  end
@@ -23,38 +23,39 @@ module Omnibus
23
23
  let(:version) { '12.4.0' }
24
24
 
25
25
  let(:project) do
26
- Project.new(<<-EOH, __FILE__)
27
- name '#{name}'
28
- maintainer 'Chef'
29
- homepage 'https://getchef.com'
30
- build_version '#{version}'
31
- install_path '#{tmp_path}\\opt\\#{name}'
32
- EOH
26
+ allow(IO).to receive(:read)
27
+ .with('/project.rb')
28
+ .and_return <<-EOH.gsub(/^ {10}/, '')
29
+ name '#{name}'
30
+ maintainer 'Chef'
31
+ homepage 'https://getchef.com'
32
+ build_version '#{version}'
33
+ install_dir '#{tmp_path}\\opt\\#{name}'
34
+ EOH
35
+
36
+ Project.load('/project.rb')
33
37
  end
34
38
 
35
39
  let(:windows_packager) { Packager::WindowsMsi.new(project) }
36
40
 
37
41
  before do
38
- # Reset stale configuration
39
- Omnibus.config.reset!
40
-
41
42
  # Tell things to install into the cache directory
42
43
  root = "#{tmp_path}/var/omnibus"
43
- Omnibus.config.cache_dir "#{root}/cache"
44
- Omnibus.config.install_path_cache_dir "#{root}/cache/install_path"
45
- Omnibus.config.source_dir "#{root}/src"
46
- Omnibus.config.build_dir "#{root}/build"
47
- Omnibus.config.package_dir "#{root}/pkg"
48
- Omnibus.config.package_tmp "#{root}/pkg-tmp"
44
+ Config.cache_dir "#{root}/cache"
45
+ Config.git_cache_dir "#{root}/cache/git_cache"
46
+ Config.source_dir "#{root}/src"
47
+ Config.build_dir "#{root}/build"
48
+ Config.package_dir "#{root}/pkg"
49
+ Config.package_tmp "#{root}/pkg-tmp"
49
50
 
50
51
  # Point at our sample project fixture
51
- Omnibus.config.project_root "#{fixtures_path}/sample"
52
+ Config.project_root "#{fixtures_path}/sample"
52
53
 
53
54
  # Create the target directory
54
- FileUtils.mkdir_p(project.install_path)
55
+ FileUtils.mkdir_p(project.install_dir)
55
56
 
56
57
  # Create a file to be included in the MSI
57
- FileUtils.touch(File.join(project.install_path, 'golden_file'))
58
+ FileUtils.touch(File.join(project.install_dir, 'golden_file'))
58
59
  end
59
60
 
60
61
  it 'builds a pkg and a dmg' do
@@ -63,7 +64,7 @@ module Omnibus
63
64
 
64
65
  # There is a tiny bit of hard-coding here, but I don't see a better
65
66
  # solution for generating the package name
66
- expect(File.exist?("#{project.package_dir}/#{name}-#{version}-1.windows.msi")).to be_true
67
+ expect(File.exist?("#{Config.package_dir}/#{name}-#{version}-1.windows.msi")).to be_truthy
67
68
  end
68
69
  end
69
70
  end
@@ -1,3 +1,6 @@
1
+ require 'rspec'
2
+ require 'rspec/its'
3
+
1
4
  require 'omnibus'
2
5
  require 'fauxhai'
3
6
 
@@ -49,11 +52,11 @@ module Omnibus
49
52
  #
50
53
  # @param [Hash] data
51
54
  #
52
- def stub_ohai(data = {})
53
- system = ::Ohai::System.new
54
- system.data = Mash.new(data)
55
+ def stub_ohai(options = {}, &block)
56
+ require 'ohai' unless defined?(Mash)
55
57
 
56
- Ohai.stub(:ohai).and_return(system)
58
+ ohai = Mash.from_hash(Fauxhai.mock(options, &block).data)
59
+ Ohai.stub(:ohai).and_return(ohai)
57
60
  end
58
61
 
59
62
  #
@@ -109,9 +112,20 @@ RSpec.configure do |config|
109
112
  # Suppress logging
110
113
  Omnibus.logger.level = :unknown
111
114
 
115
+ # Reset config
116
+ Omnibus.reset!
117
+
112
118
  # Clear the tmp_path on each run
113
119
  FileUtils.rm_rf(tmp_path)
114
120
  FileUtils.mkdir_p(tmp_path)
121
+
122
+ # Don't run Ohai - tests can still override this
123
+ stub_ohai(platform: 'ubuntu', version: '12.04')
124
+ end
125
+
126
+ config.after(:each) do
127
+ # Reset config
128
+ Omnibus.reset!
115
129
  end
116
130
 
117
131
  # Force the expect syntax
@@ -122,3 +136,28 @@ RSpec.configure do |config|
122
136
  # Run specs in a random order
123
137
  config.order = 'random'
124
138
  end
139
+
140
+ #
141
+ # Shard example group for asserting a DSL method
142
+ #
143
+ # @example
144
+ # it_behaves_like 'a cleanroom setter', :name, 'chef'
145
+ #
146
+ RSpec.shared_examples 'a cleanroom setter' do |id, value|
147
+ it "for `#{id}'" do
148
+ expect { subject.evaluate("#{id}(#{value.inspect})") }
149
+ .to_not raise_error
150
+ end
151
+ end
152
+
153
+ #
154
+ # Shard example group for asserting a DSL method
155
+ #
156
+ # @example
157
+ # it_behaves_like 'a cleanroom getter', :name
158
+ #
159
+ RSpec.shared_examples 'a cleanroom getter' do |id|
160
+ it "for `#{id}'" do
161
+ expect { subject.evaluate("#{id}") }.to_not raise_error
162
+ end
163
+ end