packaging 0.108.2 → 0.109.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/lib/packaging/artifactory.rb +15 -10
  4. data/lib/packaging/config/validations.rb +1 -1
  5. data/lib/packaging/config.rb +5 -5
  6. data/lib/packaging/deb/repo.rb +4 -4
  7. data/lib/packaging/nuget.rb +1 -1
  8. data/lib/packaging/paths.rb +4 -3
  9. data/lib/packaging/sign/msi.rb +6 -8
  10. data/lib/packaging/util/execution.rb +1 -1
  11. data/lib/packaging/util/ezbake.rb +1 -1
  12. data/lib/packaging/util/file.rb +4 -6
  13. data/lib/packaging/util/net.rb +8 -12
  14. data/lib/packaging/util/ship.rb +17 -7
  15. data/lib/packaging/util/tool.rb +1 -1
  16. data/lib/packaging/util/version.rb +7 -5
  17. data/spec/lib/packaging/config_spec.rb +300 -279
  18. data/spec/lib/packaging/deb/repo_spec.rb +138 -76
  19. data/spec/lib/packaging/deb_spec.rb +28 -25
  20. data/spec/lib/packaging/repo_spec.rb +52 -31
  21. data/spec/lib/packaging/rpm/repo_spec.rb +18 -37
  22. data/spec/lib/packaging/sign_spec.rb +22 -43
  23. data/spec/lib/packaging/tar_spec.rb +48 -44
  24. data/spec/lib/packaging/util/execution_spec.rb +32 -32
  25. data/spec/lib/packaging/util/file_spec.rb +112 -75
  26. data/spec/lib/packaging/util/gpg_spec.rb +24 -19
  27. data/spec/lib/packaging/util/jenkins_spec.rb +79 -48
  28. data/spec/lib/packaging/util/misc_spec.rb +13 -8
  29. data/spec/lib/packaging/util/net_spec.rb +193 -152
  30. data/spec/lib/packaging/util/rake_utils_spec.rb +24 -18
  31. data/spec/lib/packaging_spec.rb +7 -9
  32. data/tasks/apple.rake +7 -8
  33. data/tasks/deb.rake +1 -1
  34. data/tasks/fetch.rake +2 -2
  35. data/tasks/mock.rake +3 -3
  36. data/tasks/nightly_repos.rake +11 -9
  37. data/tasks/rpm.rake +2 -3
  38. data/tasks/ship.rake +4 -2
  39. data/tasks/sign.rake +8 -10
  40. data/tasks/z_data_dump.rake +3 -3
  41. metadata +46 -33
@@ -2,216 +2,216 @@
2
2
  require 'spec_helper'
3
3
  require 'yaml'
4
4
 
5
- describe "Pkg::Config" do
6
-
7
- Build_Params = [:apt_archive_path,
8
- :apt_archive_repo_command,
9
- :apt_host,
10
- :apt_releases,
11
- :apt_repo_path,
12
- :apt_repo_url,
13
- :apt_repo_name,
14
- :apt_repo_command,
15
- :author,
16
- :benchmark,
17
- :build_date,
18
- :build_defaults,
19
- :build_dmg,
20
- :build_doc,
21
- :build_gem,
22
- :build_ips,
23
- :build_msi,
24
- :build_pe,
25
- :build_tar,
26
- :builder_data_file,
27
- :bundle_platforms,
28
- :certificate_pem,
29
- :cows,
30
- :db_table,
31
- :deb_build_host,
32
- :deb_build_mirrors,
33
- :debversion,
34
- :debug,
35
- :default_cow,
36
- :default_mock,
37
- :description,
38
- :dmg_path,
39
- :downloads_archive_path,
40
- :email,
41
- :files,
42
- :final_mocks,
43
- :freight_archive_path,
44
- :freight_conf,
45
- :gem_default_executables,
46
- :gem_dependencies,
47
- :gem_description,
48
- :gem_devel_dependencies,
49
- :gem_development_dependencies,
50
- :gem_excludes,
51
- :gem_executables,
52
- :gem_files,
53
- :gem_forge_project,
54
- :gem_host,
55
- :gem_license,
56
- :gem_name,
57
- :gem_path,
58
- :gem_platform_dependencies,
59
- :gem_rdoc_options,
60
- :gem_require_path,
61
- :gem_required_ruby_version,
62
- :gem_required_rubygems_version,
63
- :gem_runtime_dependencies,
64
- :gem_summary,
65
- :gem_test_files,
66
- :gemversion,
67
- :gpg_key,
68
- :gpg_name,
69
- :homepage,
70
- :ips_build_host,
71
- :ips_host,
72
- :ips_inter_cert,
73
- :ips_package_host,
74
- :ips_path,
75
- :ips_repo,
76
- :ips_store,
77
- :jenkins_build_host,
78
- :jenkins_packaging_job,
79
- :jenkins_repo_path,
80
- :metrics,
81
- :metrics_url,
82
- :msi_name,
83
- :name,
84
- :nonfinal_apt_repo_command,
85
- :nonfinal_apt_repo_path,
86
- :nonfinal_apt_repo_staging_path,
87
- :nonfinal_dmg_path,
88
- :nonfinal_gem_path,
89
- :nonfinal_ips_path,
90
- :nonfinal_msi_path,
91
- :nonfinal_p5p_path,
92
- :nonfinal_repo_name,
93
- :nonfinal_repo_link_target,
94
- :nonfinal_svr4_path,
95
- :nonfinal_swix_path,
96
- :nonfinal_yum_repo_path,
97
- :notify,
98
- :project,
99
- :origversion,
100
- :osx_build_host,
101
- :packager,
102
- :packaging_repo,
103
- :packaging_root,
104
- :packaging_url,
105
- :pbuild_conf,
106
- :pe_name,
107
- :pe_version,
108
- :pg_major_version,
109
- :pre_tar_task,
110
- :pre_tasks,
111
- :privatekey_pem,
112
- :random_mockroot,
113
- :rc_mocks,
114
- :release,
115
- :rpm_build_host,
116
- :rpmrelease,
117
- :rpmversion,
118
- :ref,
119
- :repo_name,
120
- :short_ref,
121
- :sign_tar,
122
- :signing_server,
123
- :summary,
124
- :svr4_host,
125
- :svr4_path,
126
- :swix_path,
127
- :tar_excludes,
128
- :tar_host,
129
- :tarball_path,
130
- :team,
131
- :templates,
132
- :update_version_file,
133
- :version,
134
- :version_file,
135
- :version_strategy,
136
- :yum_archive_path,
137
- :yum_host,
138
- :yum_repo_path,
139
- :yum_repo_name,
140
- :yum_repo_command,
141
- ]
142
-
143
- describe "#new" do
144
- Build_Params.each do |param|
145
- it "should have r/w accessors for #{param}" do
146
- Pkg::Config.should respond_to(param)
147
- Pkg::Config.should respond_to("#{param.to_s}=")
5
+ CONFIGURATION_KEYS = %i[
6
+ apt_archive_path
7
+ apt_archive_repo_command
8
+ apt_host
9
+ apt_releases
10
+ apt_repo_path
11
+ apt_repo_url
12
+ apt_repo_name
13
+ apt_repo_command
14
+ author
15
+ benchmark
16
+ build_date
17
+ build_defaults
18
+ build_dmg
19
+ build_doc
20
+ build_gem
21
+ build_ips
22
+ build_msi
23
+ build_pe
24
+ build_tar
25
+ builder_data_file
26
+ bundle_platforms
27
+ certificate_pem
28
+ cows
29
+ db_table
30
+ deb_build_host
31
+ deb_build_mirrors
32
+ debversion
33
+ debug
34
+ default_cow
35
+ default_mock
36
+ description
37
+ dmg_path
38
+ downloads_archive_path
39
+ email
40
+ files
41
+ final_mocks
42
+ freight_archive_path
43
+ freight_conf
44
+ gem_default_executables
45
+ gem_dependencies
46
+ gem_description
47
+ gem_devel_dependencies
48
+ gem_development_dependencies
49
+ gem_excludes
50
+ gem_executables
51
+ gem_files
52
+ gem_forge_project
53
+ gem_host
54
+ gem_license
55
+ gem_name
56
+ gem_path
57
+ gem_platform_dependencies
58
+ gem_rdoc_options
59
+ gem_require_path
60
+ gem_required_ruby_version
61
+ gem_required_rubygems_version
62
+ gem_runtime_dependencies
63
+ gem_summary
64
+ gem_test_files
65
+ gemversion
66
+ gpg_key
67
+ gpg_name
68
+ homepage
69
+ ips_build_host
70
+ ips_host
71
+ ips_inter_cert
72
+ ips_package_host
73
+ ips_path
74
+ ips_repo
75
+ ips_store
76
+ jenkins_build_host
77
+ jenkins_packaging_job
78
+ jenkins_repo_path
79
+ metrics
80
+ metrics_url
81
+ msi_name
82
+ name
83
+ nonfinal_apt_repo_command
84
+ nonfinal_apt_repo_path
85
+ nonfinal_apt_repo_staging_path
86
+ nonfinal_dmg_path
87
+ nonfinal_gem_path
88
+ nonfinal_ips_path
89
+ nonfinal_msi_path
90
+ nonfinal_p5p_path
91
+ nonfinal_repo_name
92
+ nonfinal_repo_link_target
93
+ nonfinal_svr4_path
94
+ nonfinal_swix_path
95
+ nonfinal_yum_repo_path
96
+ notify
97
+ project
98
+ origversion
99
+ osx_build_host
100
+ packager
101
+ packaging_repo
102
+ packaging_root
103
+ packaging_url
104
+ pbuild_conf
105
+ pe_name
106
+ pe_version
107
+ pg_major_version
108
+ pre_tar_task
109
+ pre_tasks
110
+ privatekey_pem
111
+ random_mockroot
112
+ rc_mocks
113
+ release
114
+ rpm_build_host
115
+ rpmrelease
116
+ rpmversion
117
+ ref
118
+ repo_name
119
+ short_ref
120
+ sign_tar
121
+ signing_server
122
+ summary
123
+ svr4_host
124
+ svr4_path
125
+ swix_path
126
+ tar_excludes
127
+ tar_host
128
+ tarball_path
129
+ team
130
+ templates
131
+ update_version_file
132
+ version
133
+ version_file
134
+ version_strategy
135
+ yum_archive_path
136
+ yum_host
137
+ yum_repo_path
138
+ yum_repo_name
139
+ yum_repo_command
140
+ ]
141
+
142
+ describe 'Pkg::Config' do
143
+ describe '#new' do
144
+ CONFIGURATION_KEYS.each do |configuration_key|
145
+ it "should have r/w accessors for #{configuration_key}" do
146
+ expect(Pkg::Config).to respond_to(configuration_key)
147
+ expect(Pkg::Config).to respond_to("#{configuration_key.to_s}=")
148
148
  end
149
149
  end
150
150
  end
151
151
 
152
- describe "#config_from_hash" do
153
- good_params = { :yum_host => 'foo', :pe_name => 'bar' }
152
+ describe '#config_from_hash' do
153
+ good_params = { yum_host: 'foo', pe_name: 'bar' }
154
154
  context "given a valid params hash #{good_params}" do
155
- it "should set instance variable values for each param" do
155
+ it 'should set instance variable values for each param' do
156
156
  good_params.each do |param, value|
157
- Pkg::Config.should_receive(:instance_variable_set).with("@#{param}", value)
157
+ expect(Pkg::Config).to receive(:instance_variable_set).with("@#{param}", value)
158
158
  end
159
159
  Pkg::Config.config_from_hash(good_params)
160
160
  end
161
161
  end
162
162
 
163
- bad_params = { :foo => 'bar' }
163
+ bad_params = { foo: 'bar' }
164
164
  context "given an invalid params hash #{bad_params}" do
165
165
  bad_params.each do |param, value|
166
166
  it "should print a warning that param '#{param}' is not valid" do
167
- Pkg::Config.should_receive(:warn).with(/No build data parameter found for '#{param}'/)
167
+ expect(Pkg::Config).to receive(:warn).with(/No build data parameter found for '#{param}'/)
168
168
  Pkg::Config.config_from_hash(bad_params)
169
169
  end
170
170
 
171
171
  it "should not try to set instance variable @:#{param}" do
172
- Pkg::Config.should_not_receive(:instance_variable_set).with("@#{param}", value)
172
+ expect(Pkg::Config).to_not receive(:instance_variable_set).with("@#{param}", value)
173
173
  Pkg::Config.config_from_hash(bad_params)
174
174
  end
175
175
  end
176
176
  end
177
177
 
178
- mixed_params = { :sign_tar => true, :baz => 'qux' }
179
- context "given a hash with both valid and invalid params" do
180
- it "should set the valid param" do
181
- Pkg::Config.should_receive(:instance_variable_set).with("@sign_tar", true)
178
+ mixed_params = { sign_tar: true, baz: 'qux' }
179
+ context 'given a hash with both valid and invalid params' do
180
+ it 'should set the valid param' do
181
+ expect(Pkg::Config).to receive(:instance_variable_set).with("@sign_tar", true)
182
182
  Pkg::Config.config_from_hash(mixed_params)
183
183
  end
184
184
 
185
- it "should issue a warning that the invalid param is not valid" do
186
- Pkg::Config.should_receive(:warn).with(/No build data parameter found for 'baz'/)
185
+ it 'should issue a warning that the invalid param is not valid' do
186
+ expect(Pkg::Config).to receive(:warn).with(/No build data parameter found for 'baz'/)
187
187
  Pkg::Config.config_from_hash(mixed_params)
188
188
  end
189
189
 
190
- it "should not try to set instance variable @:baz" do
191
- Pkg::Config.should_not_receive(:instance_variable_set).with("@baz", "qux")
190
+ it 'should not try to set instance variable @:baz' do
191
+ expect(Pkg::Config).to_not receive(:instance_variable_set).with('@baz', 'qux')
192
192
  Pkg::Config.config_from_hash(mixed_params)
193
193
  end
194
194
  end
195
195
  end
196
196
 
197
- describe "#params" do
198
- it "should return a hash containing keys for all build parameters" do
197
+ describe '#params' do
198
+ it 'should return a hash containing keys for all build parameters' do
199
199
  params = Pkg::Config.config
200
- Build_Params.each { |param| params.has_key?(param).should == true }
200
+ CONFIGURATION_KEYS.each { |param| expect(params.key?(param)).to be true }
201
201
  end
202
202
  end
203
203
 
204
- describe "#platform_data" do
205
- platform_tags = [
206
- 'osx-10.15-x86_64',
207
- 'osx-11-x86_64',
208
- 'ubuntu-18.04-amd64',
209
- 'el-6-x86_64',
210
- 'el-7-ppc64le',
211
- 'sles-12-x86_64',
204
+ describe '#platform_data' do
205
+ platform_tags = %w[
206
+ osx-10.15-x86_64
207
+ osx-11-x86_64
208
+ ubuntu-18.04-amd64
209
+ el-6-x86_64
210
+ el-7-ppc64le
211
+ sles-12-x86_64
212
212
  ]
213
213
 
214
- artifacts = \
214
+ artifacts =
215
215
  "./artifacts/apple/10.15/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.osx10.15.dmg\n" \
216
216
  "./artifacts/apple/11/PC1/x86_64/puppet-agent-5.3.2.658.gc79ef9a-1.osx11.dmg\n" \
217
217
  "./artifacts/deb/bionic/PC1/puppet-agent_5.3.2-1bionic_amd64.deb\n" \
@@ -257,27 +257,27 @@ describe "Pkg::Config" do
257
257
  allow(Pkg::Util::Net).to receive(:check_host_ssh).and_return([])
258
258
  end
259
259
 
260
- it "should return a hash mapping platform tags to paths" do
260
+ it 'should return a hash mapping platform tags to paths' do
261
261
  allow(Pkg::Util::Net).to receive(:remote_execute).and_return(artifacts, nil)
262
262
  expect(Pkg::Config.platform_data.keys).to eql(platform_tags)
263
263
  end
264
264
 
265
- it "should return nil if project isn't set" do
265
+ it 'should return nil if project isn\'t set' do
266
266
  allow(Pkg::Config).to receive(:project).and_return(nil)
267
267
  expect(Pkg::Config.platform_data).to be_nil
268
268
  end
269
269
 
270
- it "should return nil if ref isn't set" do
270
+ it 'should return nil if ref isn\'t set' do
271
271
  allow(Pkg::Config).to receive(:ref).and_return(nil)
272
272
  expect(Pkg::Config.platform_data).to be_nil
273
273
  end
274
274
 
275
- it "should return nil if can't connect to build server" do
275
+ it 'should return nil if can\'t connect to build server' do
276
276
  allow(Pkg::Util::Net).to receive(:check_host_ssh).and_return(['something'])
277
277
  expect(Pkg::Config.platform_data).to be_nil
278
278
  end
279
279
 
280
- it "should not use 'f' in fedora platform tags" do
280
+ it 'should not use \'f\' in fedora platform tags' do
281
281
  allow(Pkg::Util::Net).to receive(:remote_execute).and_return(fedora_artifacts, nil)
282
282
  data = Pkg::Config.platform_data
283
283
  expect(data).to include('fedora-36-x86_64')
@@ -287,28 +287,39 @@ describe "Pkg::Config" do
287
287
  it "should collect packages whose extname differ from package_format" do
288
288
  allow(Pkg::Util::Net).to receive(:remote_execute).and_return(solaris_artifacts, nil)
289
289
  data = Pkg::Config.platform_data
290
- expect(data).to include('solaris-10-i386' => {:artifact => './solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz', :repo_config => nil})
291
- expect(data).to include('solaris-11-sparc' => {:artifact => './solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p', :repo_config => nil})
292
- end
293
-
294
- it "should collect versioned msis" do
290
+ expect(data).to include(
291
+ 'solaris-10-i386' => {
292
+ artifact: './solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz',
293
+ repo_config: nil
294
+ }
295
+ )
296
+ expect(data).to include(
297
+ 'solaris-11-sparc' => {
298
+ artifact: './solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p',
299
+ repo_config: nil
300
+ }
301
+ )
302
+ end
303
+
304
+ it 'should collect versioned msis' do
295
305
  allow(Pkg::Util::Net).to receive(:remote_execute).and_return(windows_artifacts, nil)
296
306
  data = Pkg::Config.platform_data
297
- expect(data['windows-2012-x86']).to include(:artifact => './windows/puppet-agent-5.3.2-x86.msi')
298
- expect(data['windows-2012-x64']).to include(:artifact => './windows/puppet-agent-5.3.2-x64.msi')
299
- expect(data['windowsfips-2012-x64']).to include(:artifact => './windowsfips/puppet-agent-5.3.2-x64.msi')
307
+ expect(data['windows-2012-x86']).to include(artifact: './windows/puppet-agent-5.3.2-x86.msi')
308
+ expect(data['windows-2012-x64']).to include(artifact: './windows/puppet-agent-5.3.2-x64.msi')
309
+ expect(data['windowsfips-2012-x64']).to include(artifact: './windowsfips/puppet-agent-5.3.2-x64.msi')
300
310
  end
301
311
 
302
- it "should not collect debug packages" do
312
+ it 'should not collect debug packages' do
303
313
  allow(Pkg::Util::Net).to receive(:remote_execute).and_return(buster_artifacts, nil)
304
314
  data = Pkg::Config.platform_data
305
- expect(data['debian-10-amd64']).to include(:artifact => './deb/buster/PC1/puppet-agent_5.3.2.658.gc79ef9a-1buster_amd64.deb')
315
+ expect(data['debian-10-amd64']).to include(artifact: './deb/buster/PC1/puppet-agent_5.3.2.658.gc79ef9a-1buster_amd64.deb')
306
316
  end
307
317
 
308
- it "should collect packages that don't match the project name" do
309
- allow(Pkg::Util::Net).to receive(:remote_execute).and_return(artifacts_not_matching_project, nil)
318
+ it 'should collect packages that don\'t match the project name' do
319
+ allow(Pkg::Util::Net).to receive(:remote_execute)
320
+ .and_return(artifacts_not_matching_project, nil)
310
321
  data = Pkg::Config.platform_data
311
- expect(data['ubuntu-18.04-amd64']).to include(:artifact => './deb/bionic/pe-postgresql-contrib_2019.1.9.6.12-1bionic_amd64.deb')
322
+ expect(data['ubuntu-18.04-amd64']).to include(artifact: './deb/bionic/pe-postgresql-contrib_2019.1.9.6.12-1bionic_amd64.deb')
312
323
  expect(data['ubuntu-18.04-amd64'][:additional_artifacts].size).to eq(3)
313
324
  expect(data['ubuntu-18.04-amd64'][:additional_artifacts]).to include('./deb/bionic/pe-postgresql-devel_2019.1.9.6.12-1bionic_amd64.deb')
314
325
  expect(data['ubuntu-18.04-amd64'][:additional_artifacts]).to include('./deb/bionic/pe-postgresql-server_2019.1.9.6.12-1bionic_amd64.deb')
@@ -318,162 +329,170 @@ describe "Pkg::Config" do
318
329
  it "should use 'ppc' instead of 'power' in aix paths" do
319
330
  allow(Pkg::Util::Net).to receive(:remote_execute).and_return(aix_artifacts, nil)
320
331
  data = Pkg::Config.platform_data
321
- expect(data['aix-7.1-power']).to include(:artifact => './aix/7.1/PC1/ppc/puppet-agent-5.3.2-1.aix7.1.ppc.rpm')
332
+ expect(data['aix-7.1-power']).to include(artifact: './aix/7.1/PC1/ppc/puppet-agent-5.3.2-1.aix7.1.ppc.rpm')
322
333
  end
323
334
 
324
- it "should not record an aix repo config" do
335
+ it 'should not record an aix repo config' do
325
336
  allow(Pkg::Util::Net).to receive(:remote_execute).and_return(aix_artifacts, nil)
326
337
  data = Pkg::Config.platform_data
327
338
  expect(data['aix-7.1-power'][:repo_config]).to be_nil
328
339
  end
329
340
  end
330
341
 
331
- describe "#config_to_yaml" do
332
- it "should write a valid yaml file" do
342
+ describe '#config_to_yaml' do
343
+ it 'should write a valid yaml file' do
333
344
  file = double('file')
334
- File.should_receive(:open).with(anything(), 'w').and_yield(file)
335
- file.should_receive(:puts).with(instance_of(String))
336
- YAML.should_receive(:load_file).with(file)
345
+ expect(File).to receive(:open).with(anything, 'w').and_yield(file)
346
+ expect(file).to receive(:puts).with(instance_of(String))
347
+ expect(YAML).to receive(:load_file).with(file)
337
348
  expect { YAML.load_file(file) }.to_not raise_error
338
349
  Pkg::Config.config_to_yaml
339
350
  end
340
351
  end
341
352
 
342
- describe "#get_binding" do
343
- it "should return the binding of the Pkg::Config object" do
353
+ describe '#get_binding' do
354
+ it 'should return the binding of the Pkg::Config object' do
344
355
  # test by eval'ing using the binding before and after setting a param
345
356
  orig = Pkg::Config.apt_host
346
357
  Pkg::Config.apt_host = "foo"
347
- expect(eval("@apt_host", Pkg::Config.get_binding)).to eq("foo")
358
+ expect(eval('@apt_host', Pkg::Config.get_binding, __FILE__, __LINE__)).to eq("foo")
348
359
  Pkg::Config.apt_host = "bar"
349
- expect(eval("@apt_host", Pkg::Config.get_binding)).to eq("bar")
360
+ expect(eval('@apt_host', Pkg::Config.get_binding, __FILE__, __LINE__)).to eq("bar")
350
361
  Pkg::Config.apt_host = orig
351
362
  end
352
363
  end
353
364
 
354
- describe "#config_from_yaml" do
355
- context "given a yaml file" do
356
- it "should, use it to set params" do
365
+ describe '#config_from_yaml' do
366
+ context 'given a yaml file' do
367
+ it 'should, use it to set params' do
357
368
  # apt_host: is set to "foo" in the fixture
358
369
  orig = Pkg::Config.apt_host
359
- Pkg::Config.apt_host = "bar"
370
+ Pkg::Config.apt_host = 'bar'
360
371
  Pkg::Config.config_from_yaml(File.join(FIXTURES, 'config', 'ext', 'build_defaults.yaml'))
361
- expect(Pkg::Config.apt_host).to eq("foo")
372
+ expect(Pkg::Config.apt_host).to eq('foo')
362
373
  Pkg::Config.apt_host = orig
363
374
  end
364
375
  end
365
376
  end
366
377
 
367
378
  describe "#string_to_array" do
368
- ary = %W(FOO BAR ARR RAY)
369
- context "given a string with spaces in it" do
370
- it "should return an array containing the contents of that string" do
379
+ sample_array = %w[FOO BAR ARR RAY]
380
+ context 'given a string with spaces in it' do
381
+ it 'should return an array containing the contents of that string' do
371
382
  space_str = "FOO BAR ARR RAY"
372
- expect(Pkg::Config.string_to_array(space_str)).to eq(ary)
383
+ expect(Pkg::Config.string_to_array(space_str)).to eq(sample_array)
373
384
  end
374
385
  end
375
386
 
376
- context "given a string with commas in it" do
377
- it "should return an array containing the contents of that string" do
378
- comma_str = "FOO,BAR,ARR,RAY"
379
- expect(Pkg::Config.string_to_array(comma_str)).to eq(ary)
387
+ context 'given a string with commas in it' do
388
+ it 'should return an array containing the contents of that string' do
389
+ comma_str = 'FOO,BAR,ARR,RAY'
390
+ expect(Pkg::Config.string_to_array(comma_str)).to eq(sample_array)
380
391
  end
381
392
  end
382
393
 
383
- context "given a string with semicolons in it" do
384
- it "should return an array containing the contents of that string" do
385
- semi_str = "FOO;BAR;ARR;RAY"
386
- expect(Pkg::Config.string_to_array(semi_str)).to eq(ary)
394
+ context 'given a string with semicolons in it' do
395
+ it 'should return an array containing the contents of that string' do
396
+ semi_str = 'FOO;BAR;ARR;RAY'
397
+ expect(Pkg::Config.string_to_array(semi_str)).to eq(sample_array)
387
398
  end
388
399
  end
389
400
 
390
- context "given a string with multiple delimiters in it" do
401
+ context 'given a string with multiple delimiters in it' do
391
402
  delimiters = [',', ' ', ';']
392
- mixed_str = "FOO, BAR, ARR, ; RAY"
393
- mixed_arr = Pkg::Config.string_to_array(mixed_str)
403
+ sample_string = "FOO, BAR, ARR, ; RAY"
404
+ sample_array = Pkg::Config.string_to_array(sample_string)
394
405
 
395
- it "should not return the delimiters as array items" do
396
- expect(mixed_arr).to_not include(*delimiters)
406
+ it 'should not return the delimiters as array items' do
407
+ expect(sample_array).to_not include(*delimiters)
397
408
  end
398
409
 
399
- it "should not contain empty strings" do
400
- expect(mixed_arr).to_not include("\s")
410
+ it 'should not contain empty strings' do
411
+ expect(sample_array).to_not include("\s")
401
412
  end
402
413
 
403
- it "should still return the expected array" do
404
- expect(mixed_arr).to eq(ary)
414
+ it 'should still return the expected array' do
415
+ expect(sample_array).to eq(sample_array)
405
416
  end
406
417
  end
407
418
  end
408
419
 
409
- describe "#cow_list" do
420
+ describe '#cow_list' do
410
421
  it "should return a list of the cows for a project" do
411
- Pkg::Config.cows = "base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-saucy-i386.cow base-saucy-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow base-testing-amd64.cow base-trusty-i386.cow base-trusty-amd64.cow base-unstable-i386.cow base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow"
412
- Pkg::Config.cow_list.should eq "lucid precise quantal saucy sid squeeze stable testing trusty unstable wheezy"
422
+ Pkg::Config.cows = %w[
423
+ base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow
424
+ base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-saucy-i386.cow
425
+ base-saucy-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow
426
+ base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow
427
+ base-testing-amd64.cow base-trusty-i386.cow base-trusty-amd64.cow base-unstable-i386.cow
428
+ base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow
429
+ ].join(' ')
430
+
431
+ expect(Pkg::Config.cow_list)
432
+ .to eq 'lucid precise quantal saucy sid squeeze stable testing trusty unstable wheezy'
413
433
  end
414
434
  end
415
435
 
416
- describe "#config" do
417
- context "given :format => :hash" do
418
- it "should call Pkg::Config.config_to_hash" do
436
+ describe '#config' do
437
+ context 'given :format => :hash' do
438
+ it 'should call Pkg::Config.config_to_hash' do
419
439
  expect(Pkg::Config).to receive(:config_to_hash)
420
- Pkg::Config.config(:target => nil, :format => :hash)
440
+ Pkg::Config.config(target: nil, format: :hash)
421
441
  end
422
442
  end
423
443
 
424
- context "given :format => :yaml" do
425
- it "should call Pkg::Config.config_to_yaml if given :format => :yaml" do
444
+ context 'given :format => :yaml' do
445
+ it 'should call Pkg::Config.config_to_yaml if given :format => :yaml' do
426
446
  expect(Pkg::Config).to receive(:config_to_yaml)
427
- Pkg::Config.config(:target => nil, :format => :yaml)
447
+ Pkg::Config.config(target: nil, format: :yaml)
428
448
  end
429
449
  end
430
450
  end
431
451
 
432
- describe "#issue_reassignments" do
452
+ describe '#issue_reassignments' do
433
453
  around do |example|
434
- prev_tar_host = Pkg::Config.tar_host
454
+ original_tar_host = Pkg::Config.tar_host
435
455
  Pkg::Config.tar_host = nil
436
456
  example.run
437
- Pkg::Config.tar_host = prev_tar_host
457
+ Pkg::Config.tar_host = original_tar_host
438
458
  end
439
459
 
440
- it "should set tar_host to staging_server" do
441
- Pkg::Config.config_from_hash({ :staging_server => 'foo' })
460
+ it 'should set tar_host to staging_server' do
461
+ Pkg::Config.config_from_hash({ staging_server: 'foo' })
442
462
  Pkg::Config.issue_reassignments
443
- Pkg::Config.tar_host.should eq("foo")
463
+ expect(Pkg::Config.tar_host).to eq('foo')
444
464
  end
445
465
  end
446
466
 
447
- describe "#config_to_hash" do
448
- it "should return a hash object" do
449
- hash = Pkg::Config.config_to_hash
450
- hash.should be_a(Hash)
467
+ describe '#config_to_hash' do
468
+ it 'should return a hash object' do
469
+ expect(Pkg::Config.config_to_hash).to be_a(Hash)
451
470
  end
452
471
 
453
- it "should return a hash with the current parameters" do
454
- Pkg::Config.apt_host = "foo"
455
- Pkg::Config.config_to_hash[:apt_host].should eq("foo")
456
- Pkg::Config.apt_host = "bar"
457
- Pkg::Config.config_to_hash[:apt_host].should eq("bar")
472
+ it 'should return a hash with the current parameters' do
473
+ Pkg::Config.apt_host = 'foo'
474
+ expect(Pkg::Config.config_to_hash[:apt_host]).to eq('foo')
475
+ Pkg::Config.apt_host = 'bar'
476
+ expect(Pkg::Config.config_to_hash[:apt_host]).to eq('bar')
458
477
  end
459
478
  end
460
479
 
461
- describe "#load_default_configs" do
480
+ describe '#load_default_configs' do
462
481
  before(:each) do
463
- @project_root = double('project_root')
482
+ @project_root = 'project_root'
464
483
  Pkg::Config.project_root = @project_root
465
484
  @test_project_data = File.join(Pkg::Config.project_root, 'ext', 'project_data.yaml')
466
485
  @test_build_defaults = File.join(Pkg::Config.project_root, 'ext', 'build_defaults.yaml')
467
486
  end
468
487
 
469
488
  around do |example|
470
- orig = Pkg::Config.project_root
489
+ project_root_save = Pkg::Config.project_root
471
490
  example.run
472
- Pkg::Config.project_root = orig
491
+ Pkg::Config.project_root = project_root_save
473
492
  end
474
493
 
475
- context "given ext/build_defaults.yaml and ext/project_data.yaml are readable" do
476
- it "should try to load build_defaults.yaml and project_data.yaml" do
494
+ context 'given ext/build_defaults.yaml and ext/project_data.yaml are readable' do
495
+ it 'should try to load build_defaults.yaml and project_data.yaml' do
477
496
  allow(File).to receive(:readable?).with(@test_project_data).and_return(true)
478
497
  allow(File).to receive(:readable?).with(@test_build_defaults).and_return(true)
479
498
  expect(Pkg::Config).to receive(:config_from_yaml).with(@test_project_data)
@@ -482,8 +501,8 @@ describe "Pkg::Config" do
482
501
  end
483
502
  end
484
503
 
485
- context "given ext/build_defaults.yaml is readable but ext/project_data.yaml is not" do
486
- it "should try to load build_defaults.yaml but not project_data.yaml" do
504
+ context 'given ext/build_defaults.yaml is readable but ext/project_data.yaml is not' do
505
+ it 'should try to load build_defaults.yaml but not project_data.yaml' do
487
506
  allow(File).to receive(:readable?).with(@test_project_data).and_return(false)
488
507
  allow(File).to receive(:readable?).with(@test_build_defaults).and_return(true)
489
508
  expect(Pkg::Config).to_not receive(:config_from_yaml).with(@test_project_data)
@@ -492,8 +511,8 @@ describe "Pkg::Config" do
492
511
  end
493
512
  end
494
513
 
495
- context "given ext/build_defaults.yaml is not readable but ext/project_data.yaml is" do
496
- it "should try to load build_defaults.yaml then unset project_root" do
514
+ context 'given ext/build_defaults.yaml is not readable but ext/project_data.yaml is' do
515
+ it 'should try to load build_defaults.yaml then unset project_root' do
497
516
  allow(File).to receive(:readable?).with(@test_project_data).and_return(true)
498
517
  allow(File).to receive(:readable?).with(@test_build_defaults).and_return(false)
499
518
  expect(Pkg::Config).to_not receive(:config_from_yaml).with(@test_build_defaults)
@@ -502,14 +521,14 @@ describe "Pkg::Config" do
502
521
  end
503
522
  end
504
523
 
505
- context "given ext/build_defaults.yaml and ext/project_data.yaml are not readable" do
506
- it "should not try to load build_defaults.yaml and project_data.yaml" do
524
+ context 'given ext/build_defaults.yaml and ext/project_data.yaml are not readable' do
525
+ it 'should not try to load build_defaults.yaml and project_data.yaml' do
507
526
  Pkg::Config.project_root = 'foo'
508
527
  expect(Pkg::Config).to_not receive(:config_from_yaml)
509
528
  Pkg::Config.load_default_configs
510
529
  end
511
530
 
512
- it "should set the project root to nil" do
531
+ it 'should set the project root to nil' do
513
532
  Pkg::Config.project_root = 'foo'
514
533
  Pkg::Config.load_default_configs
515
534
  expect(Pkg::Config.project_root).to be_nil
@@ -517,17 +536,17 @@ describe "Pkg::Config" do
517
536
  end
518
537
  end
519
538
 
520
- describe "#load_versioning" do
539
+ describe '#load_versioning' do
521
540
  around do |example|
522
- orig = Pkg::Config.project_root
541
+ project_root_save = Pkg::Config.project_root
523
542
  example.run
524
- Pkg::Config.project_root = orig
543
+ Pkg::Config.project_root = project_root_save
525
544
  end
526
545
 
527
546
  # We let the actual version determination testing happen in the version
528
547
  # tests. Here we just test that we try when we should.
529
- context "When project root is nil" do
530
- it "should not try to load versioning" do
548
+ context 'When project root is nil' do
549
+ it 'should not try to load versioning' do
531
550
  Pkg::Config.project_root = nil
532
551
  expect(Pkg::Util::Version).to_not receive(:git_sha_or_tag)
533
552
  Pkg::Config.load_versioning
@@ -535,38 +554,40 @@ describe "Pkg::Config" do
535
554
  end
536
555
  end
537
556
 
538
- describe "#load_envvars" do
557
+ describe '#load_envvars' do
539
558
  # We're going to pollute the environment with this test, so afterwards we
540
559
  # explicitly set everything to nil to prevent any hazardous effects on
541
560
  # the rest of the tests.
542
561
  after(:all) do
543
- reset_env(Pkg::Params::ENV_VARS.map {|hash| hash[:envvar].to_s})
562
+ reset_env(Pkg::Params::ENV_VARS.map { |hash| hash[:envvar].to_s })
544
563
  end
545
564
 
546
565
  Pkg::Params::ENV_VARS.each do |v|
547
566
  case v[:type]
548
567
  when :bool
549
568
  it "should set boolean value on #{v[:var]} for :type == :bool" do
550
- ENV[v[:envvar].to_s] = "FOO"
551
- Pkg::Util.stub(:boolean_value) {"FOO"}
569
+ ENV[v[:envvar].to_s] = 'FOO'
570
+ allow(Pkg::Util).to receive(:boolean_value).and_return('FOO')
552
571
  allow(Pkg::Config).to receive(:instance_variable_set)
553
- expect(Pkg::Util).to receive(:boolean_value).with("FOO")
554
- expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", "FOO")
572
+ expect(Pkg::Util).to receive(:boolean_value).with('FOO')
573
+ expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", 'FOO')
555
574
  Pkg::Config.load_envvars
556
575
  end
557
576
  when :array
558
577
  it "should set Pkg::Config##{v[:var]} to an Array for :type == :array" do
559
- ENV[v[:envvar].to_s] = "FOO BAR ARR RAY"
560
- Pkg::Config.stub(:string_to_array) {%w(FOO BAR ARR RAY)}
578
+ ENV[v[:envvar].to_s] = 'FOO BAR ARR RAY'
579
+ allow(Pkg::Config).to receive(:string_to_array).and_return(%w[FOO BAR ARR RAY])
561
580
  allow(Pkg::Config).to receive(:instance_variable_set)
562
- expect(Pkg::Config).to receive(:string_to_array).with("FOO BAR ARR RAY")
563
- expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", %w(FOO BAR ARR RAY))
581
+ expect(Pkg::Config).to receive(:string_to_array).with('FOO BAR ARR RAY')
582
+ expect(Pkg::Config)
583
+ .to receive(:instance_variable_set)
584
+ .with("@#{v[:var]}", %w[FOO BAR ARR RAY])
564
585
  Pkg::Config.load_envvars
565
586
  end
566
587
  else
567
588
  it "should set Pkg::Config##{v[:var]} to ENV[#{v[:envvar].to_s}]" do
568
589
  ENV[v[:envvar].to_s] = "FOO"
569
- Pkg::Util.stub(:boolean_value) {"FOO"}
590
+ allow(Pkg::Util).to receive(:boolean_value).and_return('FOO')
570
591
  allow(Pkg::Config).to receive(:instance_variable_set)
571
592
  expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", "FOO")
572
593
  Pkg::Config.load_envvars