omnibus 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +0 -2
- data/CHANGELOG.md +26 -6
- data/Gemfile +7 -0
- data/Guardfile +10 -0
- data/README.md +103 -160
- data/Rakefile +6 -1
- data/docs/Building on OSX.md +66 -0
- data/docs/omnibus-build-cache.md +75 -0
- data/lib/omnibus.rb +9 -13
- data/lib/omnibus/artifact.rb +1 -13
- data/lib/omnibus/assets/README-logo.png +0 -0
- data/lib/omnibus/assets/logo.psd +0 -0
- data/lib/omnibus/builder.rb +1 -0
- data/lib/omnibus/cli/application.rb +17 -4
- data/lib/omnibus/cli/build.rb +6 -4
- data/lib/omnibus/config.rb +33 -0
- data/lib/omnibus/exceptions.rb +20 -14
- data/lib/omnibus/health_check.rb +2 -0
- data/lib/omnibus/install_path_cache.rb +106 -0
- data/lib/omnibus/library.rb +18 -1
- data/lib/omnibus/packagers/base.rb +228 -0
- data/lib/omnibus/packagers/mac_dmg.rb +215 -0
- data/lib/omnibus/packagers/mac_pkg.rb +129 -253
- data/lib/omnibus/project.rb +89 -95
- data/lib/omnibus/s3_cacher.rb +4 -7
- data/lib/omnibus/software.rb +47 -83
- data/lib/omnibus/sugar.rb +49 -0
- data/lib/omnibus/templates/.kitchen.yml.erb +3 -0
- data/lib/omnibus/templates/Berksfile.erb +4 -0
- data/lib/omnibus/templates/Gemfile.erb +1 -1
- data/lib/omnibus/templates/mac_dmg/background.png +0 -0
- data/lib/omnibus/templates/mac_dmg/icon.png +0 -0
- data/lib/omnibus/templates/mac_pkg/background.png +0 -0
- data/lib/omnibus/templates/mac_pkg/license.html.erb +1 -0
- data/lib/omnibus/templates/mac_pkg/welcome.html.erb +9 -0
- data/lib/omnibus/templates/omnibus.rb.example.erb +31 -4
- data/lib/omnibus/version.rb +1 -1
- data/omnibus.gemspec +5 -4
- data/spec/fixtures/sample/files/mac_dmg/Resources/background.png +0 -0
- data/spec/fixtures/sample/files/mac_dmg/Resources/icon.png +0 -0
- data/spec/fixtures/sample/files/mac_pkg/Resources/background.png +0 -0
- data/spec/fixtures/sample/files/mac_pkg/Resources/license.html +1 -0
- data/spec/fixtures/sample/files/mac_pkg/Resources/welcome.html +9 -0
- data/{functional/fixtures/mac_pkg/package-scripts/functional-test-project → spec/fixtures/sample/package-scripts/sample}/postinstall +0 -0
- data/spec/functional/packagers/mac_spec.rb +74 -0
- data/spec/spec_helper.rb +14 -3
- data/spec/sugar_spec.rb +20 -0
- data/spec/{artifact_spec.rb → unit/artifact_spec.rb} +2 -3
- data/spec/{build_version_spec.rb → unit/build_version_spec.rb} +0 -0
- data/spec/{config_spec.rb → unit/config_spec.rb} +4 -0
- data/spec/{fetchers → unit/fetchers}/git_fetcher_spec.rb +0 -0
- data/spec/{fetchers → unit/fetchers}/net_fetcher_spec.rb +0 -0
- data/spec/unit/install_path_cache_spec.rb +175 -0
- data/spec/unit/library_spec.rb +67 -0
- data/spec/{omnibus_spec.rb → unit/omnibus_spec.rb} +0 -0
- data/spec/{overrides_spec.rb → unit/overrides_spec.rb} +0 -0
- data/spec/{package_release_spec.rb → unit/package_release_spec.rb} +0 -0
- data/spec/unit/packagers/base_spec.rb +221 -0
- data/spec/unit/packagers/mac_pkg_spec.rb +163 -0
- data/spec/{project_spec.rb → unit/project_spec.rb} +0 -14
- data/spec/{s3_cacher_spec.rb → unit/s3_cacher_spec.rb} +0 -0
- data/spec/{software_spec.rb → unit/software_spec.rb} +0 -1
- metadata +122 -103
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +0 -1
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +0 -1
- data/functional/packagers/mac_pkg_spec.rb +0 -72
- data/lib/omnibus/clean_tasks.rb +0 -28
- data/spec/packagers/mac_pkg_spec.rb +0 -262
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
# Why isn't this already required in omnibus?
|
2
|
-
require 'rake/dsl_definition'
|
3
|
-
|
4
1
|
require 'omnibus'
|
5
2
|
require 'fauxhai'
|
6
3
|
|
@@ -19,6 +16,14 @@ module Omnibus
|
|
19
16
|
def project_path(name)
|
20
17
|
File.join(SPEC_DATA, 'projects', "#{name}.rb")
|
21
18
|
end
|
19
|
+
|
20
|
+
def fixtures_path
|
21
|
+
File.expand_path('../fixtures', __FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
def tmp_path
|
25
|
+
File.expand_path('../../tmp', __FILE__)
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
@@ -28,6 +33,12 @@ RSpec.configure do |config|
|
|
28
33
|
config.run_all_when_everything_filtered = true
|
29
34
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
30
35
|
|
36
|
+
# Clear the tmp_path on each run
|
37
|
+
config.before(:each) do
|
38
|
+
FileUtils.rm_rf(tmp_path)
|
39
|
+
FileUtils.mkdir_p(tmp_path)
|
40
|
+
end
|
41
|
+
|
31
42
|
# Force the expect syntax
|
32
43
|
config.expect_with :rspec do |c|
|
33
44
|
c.syntax = :expect
|
data/spec/sugar_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'omnibus/project'
|
2
|
+
require 'omnibus/software'
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Omnibus::Software do
|
7
|
+
it 'includes the Chef Sugar DSL methods' do
|
8
|
+
expect(described_class).to be_method_defined(:windows?)
|
9
|
+
expect(described_class).to be_method_defined(:vagrant?)
|
10
|
+
expect(described_class).to be_method_defined(:_64_bit?)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe Omnibus::Project do
|
15
|
+
it 'includes the Chef Sugar DSL methods' do
|
16
|
+
expect(described_class).to be_method_defined(:windows?)
|
17
|
+
expect(described_class).to be_method_defined(:vagrant?)
|
18
|
+
expect(described_class).to be_method_defined(:_64_bit?)
|
19
|
+
end
|
20
|
+
end
|
@@ -32,8 +32,6 @@ describe Omnibus::Artifact do
|
|
32
32
|
|
33
33
|
let(:artifact) { Omnibus::Artifact.new(path, platforms, version: '11.4.0-1') }
|
34
34
|
|
35
|
-
let(:flat_metadata) { artifact.flat_metadata }
|
36
|
-
|
37
35
|
it 'has the path to the package' do
|
38
36
|
expect(artifact.path).to eq(path)
|
39
37
|
end
|
@@ -53,7 +51,8 @@ describe Omnibus::Artifact do
|
|
53
51
|
end
|
54
52
|
|
55
53
|
it "generates 'flat' metadata" do
|
56
|
-
expect(File).to receive(:open).
|
54
|
+
expect(File).to receive(:open).twice.with(path).and_return(content)
|
55
|
+
flat_metadata = artifact.flat_metadata
|
57
56
|
expect(flat_metadata['platform']).to eq('el')
|
58
57
|
expect(flat_metadata['platform_version']).to eq('5')
|
59
58
|
expect(flat_metadata['arch']).to eq('x86_64')
|
File without changes
|
@@ -19,12 +19,16 @@ module Omnibus
|
|
19
19
|
end
|
20
20
|
|
21
21
|
include_examples 'a configurable', :cache_dir, '/var/cache/omnibus/cache'
|
22
|
+
include_examples 'a configurable', :install_path_cache_dir, '/var/cache/omnibus/cache/install_path'
|
22
23
|
include_examples 'a configurable', :source_dir, '/var/cache/omnibus/src'
|
23
24
|
include_examples 'a configurable', :build_dir, '/var/cache/omnibus/build'
|
24
25
|
include_examples 'a configurable', :package_dir, '/var/cache/omnibus/pkg'
|
25
26
|
include_examples 'a configurable', :package_tmp, '/var/cache/omnibus/pkg-tmp'
|
26
27
|
include_examples 'a configurable', :project_root, Dir.pwd
|
27
28
|
include_examples 'a configurable', :install_dir, '/opt/chef'
|
29
|
+
include_examples 'a configurable', :build_dmg, true
|
30
|
+
include_examples 'a configurable', :dmg_window_bounds, '100, 100, 750, 600'
|
31
|
+
include_examples 'a configurable', :dmg_pkg_position, '535, 50'
|
28
32
|
include_examples 'a configurable', :use_s3_caching, false
|
29
33
|
include_examples 'a configurable', :s3_bucket, nil
|
30
34
|
include_examples 'a configurable', :s3_access_key, nil
|
File without changes
|
File without changes
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omnibus/util'
|
3
|
+
require 'omnibus/install_path_cache'
|
4
|
+
|
5
|
+
describe Omnibus::InstallPathCache do
|
6
|
+
let(:install_path) { '/opt/chef' }
|
7
|
+
|
8
|
+
let(:project) do
|
9
|
+
raw_project = <<-EOH
|
10
|
+
name "demo"
|
11
|
+
install_path "/opt/demo"
|
12
|
+
build_version "1.0.0"
|
13
|
+
maintainer 'Chef Software, Inc'
|
14
|
+
homepage 'http://getchef.com'
|
15
|
+
dependency 'preparation'
|
16
|
+
dependency 'snoopy'
|
17
|
+
dependency 'zlib'
|
18
|
+
EOH
|
19
|
+
project = Omnibus::Project.new(raw_project, 'demo.rb')
|
20
|
+
project
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:fake_software_config_file) do
|
24
|
+
File.join(Omnibus::RSpec::SPEC_DATA, 'software', 'zlib.rb')
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:zlib) do
|
28
|
+
software = Omnibus::Software.new('', fake_software_config_file, project)
|
29
|
+
software.name('zlib')
|
30
|
+
software.default_version('1.7.2')
|
31
|
+
software
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:snoopy) do
|
35
|
+
software = Omnibus::Software.new('', 'snoopy.rb', project)
|
36
|
+
software.name('snoopy')
|
37
|
+
software.default_version('1.0.0')
|
38
|
+
software
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:preparation) do
|
42
|
+
software = Omnibus::Software.new('', 'preparation.rb', project)
|
43
|
+
software.name('preparation')
|
44
|
+
software.default_version('1.0.0')
|
45
|
+
software
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:cache_path) { "/var/cache/omnibus/cache/install_path#{install_path}" }
|
49
|
+
|
50
|
+
let(:ipc) do
|
51
|
+
project.library.component_added(preparation)
|
52
|
+
project.library.component_added(snoopy)
|
53
|
+
project.library.component_added(zlib)
|
54
|
+
Omnibus::InstallPathCache.new(install_path, zlib)
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#cache_path' do
|
58
|
+
it 'returns the install path appended to the install_cache path' do
|
59
|
+
expect(ipc.cache_path).to eq('/var/cache/omnibus/cache/install_path/opt/chef')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#cache_path_exists?' do
|
64
|
+
it 'checks for existence' do
|
65
|
+
expect(File).to receive(:directory?).with(ipc.cache_path)
|
66
|
+
ipc.cache_path_exists?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#tag' do
|
71
|
+
# 13b3f7f2653e40b9d5b393659210775ac5b56f7e0009f82f85b83f5132409362
|
72
|
+
#
|
73
|
+
# Is the sha256sum of:
|
74
|
+
# cat spec/data/software/zlib.rb > t
|
75
|
+
# echo -n 'preparation-1.0.0-snoopy-1.0.0' >> t
|
76
|
+
# sha256sum t
|
77
|
+
it 'returns a tag with the softwares name, version, and hash of deps name+version' do
|
78
|
+
expect(ipc.tag).to eql('zlib-1.7.2-13b3f7f2653e40b9d5b393659210775ac5b56f7e0009f82f85b83f5132409362')
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'with no deps' do
|
82
|
+
let(:ipc) do
|
83
|
+
Omnibus::InstallPathCache.new(install_path, zlib)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'uses the shasum of the software config file' do
|
87
|
+
# gsha256sum spec/data/software/zlib.rb
|
88
|
+
# 363e6cc2475fcdd6e18b2dc10f6022d1cab498b9961e8225d8a309d18ed3c94b spec/data/software/zlib.rb
|
89
|
+
expect(ipc.tag).to eql('zlib-1.7.2-363e6cc2475fcdd6e18b2dc10f6022d1cab498b9961e8225d8a309d18ed3c94b')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#create_cache_path' do
|
95
|
+
it 'runs git init if the cache path does not exist' do
|
96
|
+
allow(File).to receive(:directory?).with(ipc.cache_path).and_return(false)
|
97
|
+
allow(File).to receive(:directory?).with(File.dirname(ipc.cache_path)).and_return(false)
|
98
|
+
expect(FileUtils).to receive(:mkdir_p).with(File.dirname(ipc.cache_path))
|
99
|
+
expect(ipc).to receive(:shellout!).with("git --git-dir=#{cache_path} init -q")
|
100
|
+
ipc.create_cache_path
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'does not run git init if the cache path exists' do
|
104
|
+
allow(File).to receive(:directory?).with(ipc.cache_path).and_return(true)
|
105
|
+
allow(File).to receive(:directory?).with(File.dirname(ipc.cache_path)).and_return(true)
|
106
|
+
expect(ipc).to_not receive(:shellout!).with("git --git-dir=#{cache_path} init -q")
|
107
|
+
ipc.create_cache_path
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#incremental' do
|
112
|
+
before(:each) do
|
113
|
+
allow(ipc).to receive(:shellout!)
|
114
|
+
allow(ipc).to receive(:create_cache_path)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'creates the cache path' do
|
118
|
+
expect(ipc).to receive(:create_cache_path)
|
119
|
+
ipc.incremental
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'adds all the changes to git' do
|
123
|
+
expect(ipc).to receive(:shellout!).with("git --git-dir=#{cache_path} --work-tree=#{install_path} add -A -f")
|
124
|
+
ipc.incremental
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'commits the backup for the software' do
|
128
|
+
expect(ipc).to receive(:shellout!).with("git --git-dir=#{cache_path} --work-tree=#{install_path} commit -q -m 'Backup of #{ipc.tag}'")
|
129
|
+
ipc.incremental
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'tags the software backup' do
|
133
|
+
expect(ipc).to receive(:shellout!).with("git --git-dir=#{cache_path} --work-tree=#{install_path} tag -f '#{ipc.tag}'")
|
134
|
+
ipc.incremental
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#restore' do
|
139
|
+
let(:git_tag_output) { "#{ipc.tag}\n" }
|
140
|
+
|
141
|
+
let(:tag_cmd) do
|
142
|
+
cmd_double = double(Mixlib::ShellOut)
|
143
|
+
allow(cmd_double).to receive(:stdout).and_return(git_tag_output)
|
144
|
+
allow(cmd_double).to receive(:error!).and_return(cmd_double)
|
145
|
+
cmd_double
|
146
|
+
end
|
147
|
+
|
148
|
+
before(:each) do
|
149
|
+
allow(ipc).to receive(:shellout).with("git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l #{ipc.tag}").and_return(tag_cmd)
|
150
|
+
allow(ipc).to receive(:shellout!).with("git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f '#{ipc.tag}'")
|
151
|
+
allow(ipc).to receive(:create_cache_path)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'creates the cache path' do
|
155
|
+
expect(ipc).to receive(:create_cache_path)
|
156
|
+
ipc.restore
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'checks for a tag with the software and version, and if it finds it, checks it out' do
|
160
|
+
expect(ipc).to receive(:shellout).with("git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l #{ipc.tag}").and_return(tag_cmd)
|
161
|
+
expect(ipc).to receive(:shellout!).with("git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f '#{ipc.tag}'")
|
162
|
+
ipc.restore
|
163
|
+
end
|
164
|
+
|
165
|
+
describe 'if the tag does not exist' do
|
166
|
+
let(:git_tag_output) { "\n" }
|
167
|
+
|
168
|
+
it 'does nothing' do
|
169
|
+
expect(ipc).to receive(:shellout).with("git --git-dir=#{cache_path} --work-tree=#{install_path} tag -l #{ipc.tag}").and_return(tag_cmd)
|
170
|
+
expect(ipc).to_not receive(:shellout!).with("git --git-dir=#{cache_path} --work-tree=#{install_path} checkout -f '#{ipc.tag}'")
|
171
|
+
ipc.restore
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omnibus/library'
|
3
|
+
require 'omnibus/project'
|
4
|
+
|
5
|
+
describe Omnibus::Library do
|
6
|
+
let(:project) { Omnibus::Project.load(project_path('chefdk')) }
|
7
|
+
let(:library) { Omnibus::Library.new(project) }
|
8
|
+
let(:erchef) { Omnibus::Software.load(software_path('erchef'), project) }
|
9
|
+
let(:zlib) { Omnibus::Software.load(software_path('zlib'), project) }
|
10
|
+
|
11
|
+
describe '#component_added' do
|
12
|
+
it 'adds the software to the component list' do
|
13
|
+
library.component_added(erchef)
|
14
|
+
expect(library.components).to eql([erchef])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does not add a component more than once' do
|
18
|
+
library.component_added(erchef)
|
19
|
+
library.component_added(erchef)
|
20
|
+
expect(library.components).to eql([erchef])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#build_order' do
|
25
|
+
let(:project) do
|
26
|
+
raw_project = <<-EOH
|
27
|
+
name "chef-server"
|
28
|
+
install_path "/opt/chef-server"
|
29
|
+
build_version "1.0.0"
|
30
|
+
maintainer 'Chef Software, Inc'
|
31
|
+
homepage 'http://getchef.com'
|
32
|
+
dependency 'preparation'
|
33
|
+
dependency 'erchef'
|
34
|
+
dependency 'chef'
|
35
|
+
EOH
|
36
|
+
Omnibus::Project.new(raw_project, 'chef-server.rb')
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:library) do
|
40
|
+
library = Omnibus::Library.new(project)
|
41
|
+
library.component_added(preparation)
|
42
|
+
library.component_added(erlang)
|
43
|
+
library.component_added(skitch)
|
44
|
+
library.component_added(erchef)
|
45
|
+
library.component_added(ruby)
|
46
|
+
library.component_added(chef)
|
47
|
+
library
|
48
|
+
end
|
49
|
+
|
50
|
+
project_deps = [:preparation, :erchef, :chef]
|
51
|
+
erchef_deps = [:erlang, :skitch]
|
52
|
+
chef_deps = [:ruby]
|
53
|
+
|
54
|
+
[project_deps, erchef_deps, chef_deps].flatten.each do |dep|
|
55
|
+
let(dep) do
|
56
|
+
software = Omnibus::Software.new('', "#{dep}.rb", 'chef-server')
|
57
|
+
software.name(dep.to_s)
|
58
|
+
software
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns an array of software descriptions, with all non top level deps first' do
|
63
|
+
expect(library.build_order).to eql([preparation, erlang, skitch, ruby, erchef, chef])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,221 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
module Omnibus
|
19
|
+
describe Packager::Base do
|
20
|
+
let(:project) do
|
21
|
+
double('project',
|
22
|
+
name: 'hamlet',
|
23
|
+
build_version: '1.0.0',
|
24
|
+
iteration: '12902349',
|
25
|
+
mac_pkg_identifier: 'com.chef.hamlet',
|
26
|
+
install_path: '/opt/hamlet',
|
27
|
+
package_scripts_path: 'package-scripts',
|
28
|
+
files_path: 'files',
|
29
|
+
package_dir: 'pkg',
|
30
|
+
package_tmp: 'pkg-tmp',
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
subject { described_class.new(project) }
|
35
|
+
|
36
|
+
it 'includes Util' do
|
37
|
+
expect(subject).to be_a(Util)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'delegates #name to @project' do
|
41
|
+
expect(subject.name).to eq(project.name)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'delegates #version to @project' do
|
45
|
+
expect(subject.version).to eq(project.build_version)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'delegates #iteration to @project' do
|
49
|
+
expect(subject.iteration).to eq(project.iteration)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'delegates #identifer to @project' do
|
53
|
+
expect(subject.identifier).to eq(project.mac_pkg_identifier)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'delegates #scripts to @project' do
|
57
|
+
expect(subject.scripts).to eq(project.package_scripts_path)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'delegates #files_path to @project' do
|
61
|
+
expect(subject.files_path).to eq(project.files_path)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'delegates #package_dir to @project' do
|
65
|
+
expect(subject.package_dir).to eq(project.package_dir)
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '.setup' do
|
69
|
+
it 'sets the value of the block' do
|
70
|
+
block = proc {}
|
71
|
+
described_class.setup(&block)
|
72
|
+
|
73
|
+
expect(described_class.setup).to eq(block)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '.validate' do
|
78
|
+
it 'sets the value of the block' do
|
79
|
+
block = proc {}
|
80
|
+
described_class.validate(&block)
|
81
|
+
|
82
|
+
expect(described_class.validate).to eq(block)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '.build' do
|
87
|
+
it 'sets the value of the block' do
|
88
|
+
block = proc {}
|
89
|
+
described_class.build(&block)
|
90
|
+
|
91
|
+
expect(described_class.build).to eq(block)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'is a required phase' do
|
95
|
+
described_class.instance_variable_set(:@build, nil)
|
96
|
+
expect { described_class.build }.to raise_error(AbstractMethod)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '.clean' do
|
101
|
+
it 'sets the value of the block' do
|
102
|
+
block = proc {}
|
103
|
+
described_class.clean(&block)
|
104
|
+
|
105
|
+
expect(described_class.clean).to eq(block)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#create_directory' do
|
110
|
+
before { FileUtils.stub(:mkdir_p) }
|
111
|
+
|
112
|
+
it 'creates the directory' do
|
113
|
+
expect(FileUtils).to receive(:mkdir_p).with('/foo/bar')
|
114
|
+
subject.create_directory('/foo/bar')
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'returns the path' do
|
118
|
+
expect(subject.create_directory('/foo/bar')).to eq('/foo/bar')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe '#remove_directory' do
|
123
|
+
before { FileUtils.stub(:rm_rf) }
|
124
|
+
|
125
|
+
it 'remove the directory' do
|
126
|
+
expect(FileUtils).to receive(:rm_rf).with('/foo/bar')
|
127
|
+
subject.remove_directory('/foo/bar')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#purge_directory' do
|
132
|
+
before do
|
133
|
+
subject.stub(:remove_directory)
|
134
|
+
subject.stub(:create_directory)
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'removes and creates the directory' do
|
138
|
+
expect(subject).to receive(:remove_directory).with('/foo/bar')
|
139
|
+
expect(subject).to receive(:create_directory).with('/foo/bar')
|
140
|
+
subject.purge_directory('/foo/bar')
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#copy_file' do
|
145
|
+
before { FileUtils.stub(:cp) }
|
146
|
+
|
147
|
+
it 'copies the file' do
|
148
|
+
expect(FileUtils).to receive(:cp).with('foo', 'bar')
|
149
|
+
subject.copy_file('foo', 'bar')
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'returns the destination path' do
|
153
|
+
expect(subject.copy_file('foo', 'bar')).to eq('bar')
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe '#remove_file' do
|
158
|
+
before { FileUtils.stub(:rm_f) }
|
159
|
+
|
160
|
+
it 'removes the file' do
|
161
|
+
expect(FileUtils).to receive(:rm_f).with('/foo/bar')
|
162
|
+
subject.remove_file('/foo/bar')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#execute' do
|
167
|
+
before { subject.stub(:shellout!) }
|
168
|
+
|
169
|
+
it 'shellsout' do
|
170
|
+
expect(subject).to receive(:shellout!)
|
171
|
+
.with('echo "hello"', timeout: 3600, cwd: anything)
|
172
|
+
subject.execute('echo "hello"')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe '#assert_presence!' do
|
177
|
+
it 'raises a MissingAsset exception when the file does not exist' do
|
178
|
+
File.stub(:exist?).and_return(false)
|
179
|
+
expect { subject.assert_presence!('foo') }.to raise_error(MissingAsset)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '#run!' do
|
184
|
+
before do
|
185
|
+
described_class.stub(:validate).and_return(proc {})
|
186
|
+
described_class.stub(:setup).and_return(proc {})
|
187
|
+
described_class.stub(:build).and_return(proc {})
|
188
|
+
described_class.stub(:clean).and_return(proc {})
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'calls the methods in order' do
|
192
|
+
expect(described_class).to receive(:validate).ordered
|
193
|
+
expect(described_class).to receive(:setup).ordered
|
194
|
+
expect(described_class).to receive(:build).ordered
|
195
|
+
expect(described_class).to receive(:clean).ordered
|
196
|
+
subject.run!
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe '#staging_dir' do
|
201
|
+
it 'is the project package tmp and underscored named' do
|
202
|
+
name = "#{project.package_tmp}/base"
|
203
|
+
expect(subject.send(:staging_dir)).to eq(File.expand_path(name))
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe '#resource' do
|
208
|
+
it 'prefixes to the resources_path' do
|
209
|
+
path = 'files/base/Resources/icon.png'
|
210
|
+
expect(subject.send(:resource, 'icon.png')).to eq(File.expand_path(path))
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe '#resoures_path' do
|
215
|
+
it 'is the files_path, underscored_name, and Resources' do
|
216
|
+
path = "#{project.files_path}/base/Resources"
|
217
|
+
expect(subject.send(:resources_path)).to eq(File.expand_path(path))
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|