packaging 0.108.1 → 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 (43) 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/rpm/repo.rb +26 -8
  10. data/lib/packaging/sign/msi.rb +6 -8
  11. data/lib/packaging/sign/rpm.rb +8 -6
  12. data/lib/packaging/util/execution.rb +1 -1
  13. data/lib/packaging/util/ezbake.rb +1 -1
  14. data/lib/packaging/util/file.rb +4 -6
  15. data/lib/packaging/util/net.rb +8 -12
  16. data/lib/packaging/util/ship.rb +17 -7
  17. data/lib/packaging/util/tool.rb +1 -1
  18. data/lib/packaging/util/version.rb +7 -5
  19. data/spec/lib/packaging/config_spec.rb +300 -279
  20. data/spec/lib/packaging/deb/repo_spec.rb +138 -76
  21. data/spec/lib/packaging/deb_spec.rb +28 -25
  22. data/spec/lib/packaging/repo_spec.rb +52 -31
  23. data/spec/lib/packaging/rpm/repo_spec.rb +109 -71
  24. data/spec/lib/packaging/sign_spec.rb +22 -43
  25. data/spec/lib/packaging/tar_spec.rb +48 -44
  26. data/spec/lib/packaging/util/execution_spec.rb +32 -32
  27. data/spec/lib/packaging/util/file_spec.rb +112 -75
  28. data/spec/lib/packaging/util/gpg_spec.rb +24 -19
  29. data/spec/lib/packaging/util/jenkins_spec.rb +79 -48
  30. data/spec/lib/packaging/util/misc_spec.rb +13 -8
  31. data/spec/lib/packaging/util/net_spec.rb +193 -152
  32. data/spec/lib/packaging/util/rake_utils_spec.rb +24 -18
  33. data/spec/lib/packaging_spec.rb +7 -9
  34. data/tasks/apple.rake +7 -8
  35. data/tasks/deb.rake +1 -1
  36. data/tasks/fetch.rake +2 -2
  37. data/tasks/mock.rake +3 -3
  38. data/tasks/nightly_repos.rake +11 -9
  39. data/tasks/rpm.rake +2 -3
  40. data/tasks/ship.rake +4 -2
  41. data/tasks/sign.rake +8 -10
  42. data/tasks/z_data_dump.rake +3 -3
  43. metadata +48 -35
@@ -1,20 +1,22 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Pkg::Rpm::Repo" do
4
- let(:wget) { "/opt/tools/bin/wget" }
5
- let(:builds_server) { "saturn.puppetlabs.net" }
6
- let(:project) { "rpm_repos" }
7
- let(:ref) { "1234abcd" }
3
+ describe 'Pkg::Rpm::Repo' do
4
+ let(:wget) { '/opt/tools/bin/wget' }
5
+ let(:builds_server) { 'saturn.puppetlabs.net' }
6
+ let(:project) { 'rpm_repos' }
7
+ let(:ref) { '1234abcd' }
8
8
  let(:base_url) { "http://#{builds_server}/#{project}/#{ref}" }
9
- let(:mocks) { ["el-5-i386", "el-5-x86_64", "el-5-SRPMS"] }
10
- let(:wget_results) {
11
- mocks.map do |mock|
12
- dist, version, arch = mock.split('-')
13
- "http://#{builds_server}/#{project}/#{ref}/repos/#{dist}/#{version}/products/#{arch}/repodata/"
14
- end.join("\n")
15
- }
16
- let(:wget_garbage) { "\nother things\n and an index\nhttp://somethingelse.com" }
17
- let(:repo_configs) { mocks.map { |mock| "pkg/repo_configs/rpm/pl-#{project}-#{ref}-#{mock}.repo" } }
9
+ let(:mocks) { ['el-5-i386', 'el-5-x86_64', 'el-5-SRPMS'] }
10
+ let(:wget_results) do
11
+ mocks.map do |mock|
12
+ dist, version, arch = mock.split('-')
13
+ "http://#{builds_server}/#{project}/#{ref}/repos/#{dist}/#{version}/products/#{arch}/repodata/"
14
+ end.join("\n")
15
+ end
16
+ let(:wget_garbage) { "\nother things\n and an index\nhttp://somethingelse.com" }
17
+ let(:repo_configs) do
18
+ mocks.map { |mock| "pkg/repo_configs/rpm/pl-#{project}-#{ref}-#{mock}.repo" }
19
+ end
18
20
 
19
21
  # Setup and tear down for the tests
20
22
  around do |example|
@@ -34,99 +36,135 @@ describe "Pkg::Rpm::Repo" do
34
36
  Pkg::Config.jenkins_repo_path = orig_repo_path
35
37
  end
36
38
 
37
- describe "#generate_repo_configs" do
38
- it "fails if wget isn't available" do
39
- Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false}
40
- expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError)
39
+ describe '#generate_repo_configs' do
40
+ it 'fails if wget isn\'t available' do
41
+ allow(Pkg::Util::Tool)
42
+ .to receive(:find_tool)
43
+ .with('wget', { required: true })
44
+ .and_return false
45
+ expect { Pkg::Rpm::Repo.generate_repo_configs }.to raise_error(RuntimeError)
41
46
  end
42
47
 
43
- it "warns if there are no rpm repos available for the build" do
44
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
45
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return("")
46
- Pkg::Rpm::Repo.should_receive(:warn).with("No rpm repos were found to generate configs from!")
48
+ it 'warns if there are no rpm repos available for the build' do
49
+ expect(Pkg::Util::Tool)
50
+ .to receive(:find_tool)
51
+ .with('wget', { required: true })
52
+ .and_return(wget)
53
+ expect(Pkg::Util::Execution)
54
+ .to receive(:capture3)
55
+ .with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1")
56
+ .and_return('')
57
+ expect(Pkg::Rpm::Repo)
58
+ .to receive(:warn)
59
+ .with("No rpm repos were found to generate configs from!")
47
60
  Pkg::Rpm::Repo.generate_repo_configs
48
61
  end
49
62
 
50
- it "writes the expected repo configs to disk" do
51
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
52
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return(wget_results + wget_garbage)
63
+ it 'writes the expected repo configs to disk' do
64
+ expect(Pkg::Util::Tool)
65
+ .to receive(:find_tool)
66
+ .with('wget', { required: true })
67
+ .and_return(wget)
68
+ expect(Pkg::Util::Execution)
69
+ .to receive(:capture3)
70
+ .with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1")
71
+ .and_return(wget_results + wget_garbage)
53
72
  wget_results.split.each do |result|
54
73
  cur_result = result.chomp('repodata/')
55
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 1 --no-parent #{cur_result} 2>&1").and_return("#{cur_result}/thing.rpm")
74
+ expect(Pkg::Util::Execution)
75
+ .to receive(:capture3)
76
+ .with("#{wget} --spider -r -l 1 --no-parent #{cur_result} 2>&1")
77
+ .and_return("#{cur_result}/thing.rpm")
56
78
  end
57
- FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs/rpm")
79
+ expect(FileUtils).to receive(:mkdir_p).with("pkg/repo_configs/rpm")
58
80
  config = []
59
81
  repo_configs.each_with_index do |repo_config, i|
60
- Pkg::Paths.should_receive(:tag_from_artifact_path).and_return(mocks[i])
61
- Pkg::Platforms.should_receive(:parse_platform_tag).and_return(mocks[i].split('-'))
82
+ expect(Pkg::Paths).to receive(:tag_from_artifact_path).and_return(mocks[i])
83
+ expect(Pkg::Platforms).to receive(:parse_platform_tag).and_return(mocks[i].split('-'))
62
84
  config[i] = double(File)
63
- File.should_receive(:open).with(repo_config, 'w').and_yield(config[i])
64
- config[i].should_receive(:puts)
85
+ expect(File).to receive(:open).with(repo_config, 'w').and_yield(config[i])
86
+ expect(config[i]).to receive(:puts)
65
87
  end
66
88
  Pkg::Rpm::Repo.generate_repo_configs
67
89
  end
68
90
  end
69
91
 
70
92
  describe "#retrieve_repo_configs" do
71
- it "fails if wget isn't available" do
72
- Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false}
73
- expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError)
74
- end
75
-
76
93
  it "fails if there are no deb repos available for the build" do
77
- Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget)
78
- FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs").and_return(true)
79
- Pkg::Util::Execution.should_receive(:capture3).with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/rpm/").and_raise(RuntimeError)
80
- expect {Pkg::Rpm::Repo.retrieve_repo_configs}.to raise_error(RuntimeError, /Couldn't retrieve rpm yum repo configs/)
94
+ expect(Pkg::Util::Tool)
95
+ .to receive(:find_tool)
96
+ .with('wget', { required: true })
97
+ .and_return(wget)
98
+ expect(FileUtils).to receive(:mkdir_p).with('pkg/repo_configs').and_return(true)
99
+ expect(Pkg::Util::Execution)
100
+ .to receive(:capture3)
101
+ .with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/rpm/")
102
+ .and_raise(RuntimeError)
103
+ expect { Pkg::Rpm::Repo.retrieve_repo_configs }
104
+ .to raise_error(RuntimeError, /Couldn't retrieve rpm yum repo configs/)
81
105
  end
82
106
  end
83
107
 
84
- describe "#create_local_repos" do
85
- let(:command) { "/usr/bin/make some repos" }
86
- let(:target_directory) { "/tmp/dir/thing" }
108
+ describe '#create_local_repos' do
109
+ let(:command) { '/usr/bin/make some repos' }
110
+ let(:target_directory) { '/tmp/dir/thing' }
87
111
 
88
- it "makes a repo in the target directory" do
89
- Pkg::Rpm::Repo.should_receive(:repo_creation_command).with(target_directory).and_return("run this thing")
90
- Pkg::Util::Execution.should_receive(:capture3).with("bash -c 'run this thing'")
112
+ it 'makes a repo in the target directory' do
113
+ expect(Pkg::Rpm::Repo)
114
+ .to receive(:repo_creation_command)
115
+ .with(target_directory)
116
+ .and_return('run this thing')
117
+ expect(Pkg::Util::Execution).to receive(:capture3).with("bash -c 'run this thing'")
91
118
  Pkg::Rpm::Repo.create_local_repos(target_directory)
92
119
  end
93
120
  end
94
121
 
95
- describe "#create_remote_repos" do
96
- let(:command) { "/usr/bin/make some repos" }
97
- let(:artifact_directory) { "/tmp/dir/thing" }
122
+ describe '#create_remote_repos' do
123
+ let(:command) { '/usr/bin/make some repos' }
124
+ let(:artifact_directory) { '/tmp/dir/thing' }
98
125
  let(:pkg_directories) { ['el-6-i386', 'el/7/x86_64'] }
99
126
 
100
- it "makes a repo in the target directory" do
101
- File.stub(:join) {artifact_directory}
102
- Pkg::Repo.should_receive(:directories_that_contain_packages).and_return(pkg_directories)
103
- Pkg::Repo.should_receive(:populate_repo_directory)
104
- Pkg::Rpm::Repo.should_receive(:repo_creation_command).and_return(command)
105
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, command)
106
- Pkg::Rpm::Repo.should_receive(:generate_repo_configs)
107
- Pkg::Rpm::Repo.should_receive(:ship_repo_configs)
108
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" )
127
+ it 'makes a repo in the target directory' do
128
+ allow(File).to receive(:join).and_return(artifact_directory)
129
+ expect(Pkg::Repo).to receive(:directories_that_contain_packages).and_return(pkg_directories)
130
+ expect(Pkg::Repo).to receive(:populate_repo_directory)
131
+ expect(Pkg::Rpm::Repo).to receive(:repo_creation_command).and_return(command)
132
+ expect(Pkg::Util::Net)
133
+ .to receive(:remote_execute)
134
+ .with(Pkg::Config.distribution_server, command)
135
+ expect(Pkg::Rpm::Repo).to receive(:generate_repo_configs)
136
+ expect(Pkg::Rpm::Repo).to receive(:ship_repo_configs)
137
+ expect(Pkg::Util::Net)
138
+ .to receive(:remote_execute)
139
+ .with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock")
109
140
  Pkg::Rpm::Repo.create_remote_repos
110
141
  end
111
142
  end
112
143
 
113
- describe "#ship_repo_configs" do
114
- it "warn if there are no repo configs to ship" do
115
- Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/rpm").and_return(true)
116
- Pkg::Rpm::Repo.should_receive(:warn).with("No repo configs have been generated! Try pl:rpm_repo_configs.")
144
+ describe '#ship_repo_configs' do
145
+ it 'warn if there are no repo configs to ship' do
146
+ Pkg::Config.jenkins_repo_path = '/a/b/c/d'
147
+ expect(Dir).to receive(:exist?).with("pkg/repo_configs/rpm").and_return(true)
148
+ expect(Dir).to receive(:empty?).with("pkg/repo_configs/rpm").and_return(true)
149
+ expect(Pkg::Rpm::Repo)
150
+ .to receive(:warn)
151
+ .with(/^No repo_configs found in.*Skipping repo shipping/)
117
152
  Pkg::Rpm::Repo.ship_repo_configs
118
153
  end
119
154
 
120
- it "ships repo configs to the build server" do
121
- Pkg::Config.jenkins_repo_path = "/a/b/c/d"
122
- Pkg::Config.project = "thing2"
123
- Pkg::Config.ref = "abcd1234"
124
- Pkg::Config.distribution_server = "a.host.that.wont.exist"
155
+ it 'ships repo configs to the build server' do
156
+ Pkg::Config.jenkins_repo_path = '/a/b/c/d'
157
+ Pkg::Config.project = 'thing2'
158
+ Pkg::Config.ref = 'abcd1234'
159
+ Pkg::Config.distribution_server = 'a.host.that.wont.exist'
125
160
  repo_dir = "#{Pkg::Config.jenkins_repo_path}/#{Pkg::Config.project}/#{Pkg::Config.ref}/repo_configs/rpm"
126
- Pkg::Util::File.should_receive(:empty_dir?).with("pkg/repo_configs/rpm").and_return(false)
127
- Pkg::Util::RakeUtils.should_receive(:invoke_task).with("pl:fetch")
128
- Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
129
- Pkg::Util::Execution.should_receive(:retry_on_fail).with(:times => 3)
161
+ expect(Dir).to receive(:exist?).with("pkg/repo_configs/rpm").and_return(true)
162
+ expect(Dir).to receive(:empty?).with("pkg/repo_configs/rpm").and_return(false)
163
+ expect(Pkg::Util::RakeUtils).to receive(:invoke_task).with('pl:fetch')
164
+ expect(Pkg::Util::Net)
165
+ .to receive(:remote_execute)
166
+ .with(Pkg::Config.distribution_server, "mkdir -p #{repo_dir}")
167
+ expect(Pkg::Util::Execution).to receive(:retry_on_fail).with(times: 3)
130
168
  Pkg::Rpm::Repo.ship_repo_configs
131
169
  end
132
170
  end
@@ -7,7 +7,7 @@ describe 'Pkg::Sign' do
7
7
  allow(Pkg::Config).to receive(:gpg_key).and_return('7F438280EF8D349F')
8
8
  end
9
9
 
10
- describe '#signed?' do
10
+ describe '#has_sig?' do
11
11
  let(:rpm) { 'foo.rpm' }
12
12
  let(:el7_signed_response) do
13
13
  <<~DOC
@@ -17,7 +17,6 @@ describe 'Pkg::Sign' do
17
17
  MD5 digest: OK (d5f06ba2a9053de532326d0659ec0d11)
18
18
  DOC
19
19
  end
20
-
21
20
  let(:sles12_signed_response) do
22
21
  <<~DOC
23
22
  Header V4 RSA/SHA256 Signature, key ID ef8d349f: NOKEY
@@ -26,36 +25,34 @@ describe 'Pkg::Sign' do
26
25
  MD5 digest: OK (3093a09ac39bc17751f913e19ca74432)
27
26
  DOC
28
27
  end
29
-
30
28
  let(:unsigned_response) do
31
29
  <<~DOC
32
30
  Header SHA1 digest: OK (f9404cc95f200568c2dbb1fd24e1119e3e4a40a9)
33
31
  MD5 digest: OK (816095f3cee145091c3fa07a0915ce85)
34
32
  DOC
35
33
  end
36
-
37
34
  it 'returns true if rpm has been signed (el7)' do
38
35
  allow(Pkg::Sign::Rpm).to receive(:`).and_return(el7_signed_response)
39
- expect(Pkg::Sign::Rpm.signed?(rpm)).to be true
36
+ expect(Pkg::Sign::Rpm.has_sig?(rpm)).to be true
40
37
  end
41
38
  it 'returns true if rpm has been signed (sles12)' do
42
39
  allow(Pkg::Sign::Rpm).to receive(:`).and_return(sles12_signed_response)
43
- expect(Pkg::Sign::Rpm.signed?(rpm)).to be true
40
+ expect(Pkg::Sign::Rpm.has_sig?(rpm)).to be true
44
41
  end
45
42
  it 'returns false if rpm has not been signed' do
46
43
  allow(Pkg::Sign::Rpm).to receive(:`).and_return(unsigned_response)
47
- expect(Pkg::Sign::Rpm.signed?(rpm)).to be false
44
+ expect(Pkg::Sign::Rpm.has_sig?(rpm)).to be false
48
45
  end
49
46
  it 'fails with unexpected output' do
50
47
  allow(Pkg::Sign::Rpm)
51
48
  .to receive(:`)
52
49
  .and_return('something that is definitely not a normal response')
53
- expect { Pkg::Sign::Rpm.signed?(rpm) }
50
+ expect { Pkg::Sign::Rpm.has_sig?(rpm) }
54
51
  .to raise_error(RuntimeError, /Something went wrong checking the signature/)
55
52
  end
56
53
  it 'fails if gpg_key is not set' do
57
54
  allow(Pkg::Config).to receive(:gpg_key).and_return(nil)
58
- expect { Pkg::Sign::Rpm.signed?(rpm) }
55
+ expect { Pkg::Sign::Rpm.has_sig?(rpm) }
59
56
  .to raise_error(RuntimeError, /You need to set `gpg_key` in your build defaults./)
60
57
  end
61
58
  end
@@ -63,59 +60,41 @@ describe 'Pkg::Sign' do
63
60
  describe '#sign_all' do
64
61
  let(:rpm_directory) { Dir.mktmpdir }
65
62
  let(:rpms_not_to_sign) do
66
- ["#{rpm_directory}/aix/7.1/PC1/ppc/puppet-agent-5.5.3-1.aix7.1.ppc.rpm"]
63
+ %W[#{rpm_directory}/aix/7.1/PC1/ppc/puppet-agent-5.5.3-1.aix7.1.ppc.rpm]
67
64
  end
68
-
69
65
  let(:v3_rpms) do
70
- ["#{rpm_directory}/sles/11/PC1/x86_64/puppet-agent-5.5.3-1.sles11.x86_64.rpm"]
66
+ %W[#{rpm_directory}/sles/11/PC1/x86_64/puppet-agent-5.5.3-1.sles11.x86_64.rpm]
71
67
  end
72
-
73
68
  let(:v4_rpms) do
74
- ["#{rpm_directory}/el/7/PC1/aarch64/puppet-agent-5.5.3-1.el7.aarch64.rpm"]
69
+ %W[%#{rpm_directory}/el/7/PC1/aarch64/puppet-agent-5.5.3-1.el7.aarch64.rpm]
75
70
  end
76
-
77
71
  let(:rpms) { rpms_not_to_sign + v3_rpms + v4_rpms }
78
-
79
72
  let(:already_signed_rpms) do
80
- ["#{rpm_directory}/el/6/PC1/x86_64/puppet-agent-5.5.3-1.el6.x86_64.rpm"]
73
+ %W[#{rpm_directory}/el/6/PC1/x86_64/puppet-agent-5.5.3-1.el6.x86_64.rpm]
81
74
  end
82
-
83
75
  let(:noarch_rpms) do
84
- [
85
- "#{rpm_directory}/el/6/puppet5/i386/puppetserver-5.3.3-1.el6.noarch.rpm",
86
- "#{rpm_directory}/el/6/puppet5/x86_64/puppetserver-5.3.3-1.el6.noarch.rpm",
87
- "#{rpm_directory}/el/7/puppet5/i386/puppetserver-5.3.3-1.el7.noarch.rpm",
88
- "#{rpm_directory}/el/7/puppet5/x86_64/puppetserver-5.3.3-1.el7.noarch.rpm",
89
- "#{rpm_directory}/sles/12/puppet5/i386/puppetserver-5.3.3-1.sles12.noarch.rpm",
90
- "#{rpm_directory}/sles/12/puppet5/x86_64/puppetserver-5.3.3-1.sles12.noarch.rpm"
76
+ %W[
77
+ #{rpm_directory}/el/6/puppet5/i386/puppetserver-5.3.3-1.el6.noarch.rpm
78
+ #{rpm_directory}/el/6/puppet5/x86_64/puppetserver-5.3.3-1.el6.noarch.rpm
79
+ #{rpm_directory}/el/7/puppet5/i386/puppetserver-5.3.3-1.el7.noarch.rpm
80
+ #{rpm_directory}/el/7/puppet5/x86_64/puppetserver-5.3.3-1.el7.noarch.rpm
81
+ #{rpm_directory}/sles/12/puppet5/i386/puppetserver-5.3.3-1.sles12.noarch.rpm
82
+ #{rpm_directory}/sles/12/puppet5/x86_64/puppetserver-5.3.3-1.sles12.noarch.rpm
91
83
  ]
92
84
  end
93
-
94
85
  it 'signs both v3 and v4 rpms' do
95
86
  allow(Dir).to receive(:[]).with("#{rpm_directory}/**/*.rpm").and_return(rpms)
96
87
  rpms.each do |rpm|
97
88
  allow(Pkg::Sign::Rpm).to receive(:signed?).and_return(false)
98
89
  end
99
-
100
- v3_items = v3_rpms.length
101
- v4_items = v4_rpms.length
102
-
103
- expect(Pkg::Sign::Rpm)
104
- .to receive(:sign)
105
- .with(v3_rpms.join(' '), :v3)
106
- .exactly(v3_items).times
107
- expect(Pkg::Sign::Rpm)
108
- .to receive(:sign)
109
- .with(v4_rpms.join(' '), :v4)
110
- .exactly(v4_items).times
111
-
90
+ expect(Pkg::Sign::Rpm).to receive(:sign).with(v3_rpms.join(' '), :v3)
91
+ expect(Pkg::Sign::Rpm).to receive(:sign).with(v4_rpms.join(' '), :v4)
112
92
  Pkg::Sign::Rpm.sign_all(rpm_directory)
113
93
  end
114
94
 
115
95
  it 'does not sign AIX rpms' do
116
96
  allow(Dir).to receive(:[]).with("#{rpm_directory}/**/*.rpm").and_return(rpms_not_to_sign)
117
- allow(Pkg::Sign::Rpm).to receive(:signed?)
118
- expect(Pkg::Sign::Rpm).to_not receive(:legacy_sign)
97
+ allow(Pkg::Sign::Rpm).to receive(:signed?).and_return(false)
119
98
  expect(Pkg::Sign::Rpm).to_not receive(:sign)
120
99
  Pkg::Sign::Rpm.sign_all(rpm_directory)
121
100
  end
@@ -133,7 +112,7 @@ describe 'Pkg::Sign' do
133
112
  it 'deletes and relinks rpms with the same basename' do
134
113
  allow(Dir).to receive(:[]).with("#{rpm_directory}/**/*.rpm").and_return(noarch_rpms)
135
114
  allow(Pkg::Sign::Rpm).to receive(:sign)
136
- allow(Pkg::Sign::Rpm).to receive(:signed?)
115
+ allow(Pkg::Sign::Rpm).to receive(:signed?).and_return(false)
137
116
  expect(FileUtils).to receive(:rm).exactly(noarch_rpms.count / 2).times
138
117
  expect(FileUtils).to receive(:ln).exactly(noarch_rpms.count / 2).times
139
118
  Pkg::Sign::Rpm.sign_all(rpm_directory)
@@ -141,7 +120,7 @@ describe 'Pkg::Sign' do
141
120
 
142
121
  it 'does not fail if there are no rpms to sign' do
143
122
  allow(Dir).to receive(:[]).with("#{rpm_directory}/**/*.rpm").and_return([])
144
- expect(Pkg::Sign::Rpm.sign_all(rpm_directory)).to_not raise_error
123
+ expect { Pkg::Sign::Rpm.sign_all(rpm_directory) }.to_not raise_error
145
124
  end
146
125
  end
147
126
  end
@@ -1,35 +1,36 @@
1
1
  # -*- ruby -*-
2
2
  require 'spec_helper'
3
3
 
4
- describe "tar.rb" do
5
- let(:project) { "packaging" }
6
- let(:version) { "1.2.3" }
7
- let(:files) { [ "a", "b", "c" ] }
4
+ describe 'tar.rb' do
5
+ let(:project) { 'packaging' }
6
+ let(:version) { '1.2.3' }
7
+ let(:files) { %w[a b c] }
8
8
  let(:templates) do
9
9
  [
10
- "ext/redhat/spec.erb",
11
- { "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" },
12
- "ext/debian/changelog.erb",
13
- "ext/packaging/thing.erb"
10
+ 'ext/redhat/spec.erb',
11
+ { 'source' => 'ext/debian/control.erb', 'target' => 'ext/debian/not-a-control-file' },
12
+ 'ext/debian/changelog.erb',
13
+ 'ext/packaging/thing.erb'
14
14
  ]
15
15
  end
16
16
  let(:expanded_templates) do
17
17
  [
18
18
  "#{PROJECT_ROOT}/ext/redhat/spec.erb",
19
- { "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" },
19
+ { 'source' => 'ext/debian/control.erb', 'target' => 'ext/debian/not-a-control-file' },
20
20
  "#{PROJECT_ROOT}/ext/debian/changelog.erb"
21
21
  ]
22
22
  end
23
23
  before(:each) do
24
24
  Pkg::Config.config_from_hash(
25
25
  {
26
- :templates => templates,
27
- :project => project,
28
- :version => version,
29
- :files => files,
30
- :project_root => PROJECT_ROOT,
31
- :packaging_root => "ext/packaging"
32
- })
26
+ templates: templates,
27
+ project: project,
28
+ version: version,
29
+ files: files,
30
+ project_root: PROJECT_ROOT,
31
+ packaging_root: 'ext/packaging'
32
+ }
33
+ )
33
34
  end
34
35
 
35
36
  describe '#initialize' do
@@ -51,63 +52,66 @@ describe "tar.rb" do
51
52
  end
52
53
  end
53
54
 
54
- describe "#expand_templates" do
55
- it "should be invoked when Pkg::Config.templates is set" do
56
- Pkg::Tar.any_instance.should_receive(:expand_templates)
55
+ describe '#expand_templates' do
56
+ it 'should be invoked when Pkg::Config.templates is set' do
57
+ expect_any_instance_of(Pkg::Tar).to receive(:expand_templates)
57
58
  Pkg::Tar.new
58
59
  end
59
60
 
60
- it "packaging templates should be filtered and paths should be expanded" do
61
+ it 'packaging templates should be filtered and paths should be expanded' do
61
62
  templates.each do |temp|
62
63
  if temp.is_a?(String)
63
- Dir.stub(:glob).with(File.join(PROJECT_ROOT, temp)).and_return(File.join(PROJECT_ROOT, temp))
64
+ allow(Dir)
65
+ .to receive(:glob)
66
+ .with(File.join(PROJECT_ROOT, temp))
67
+ .and_return(File.join(PROJECT_ROOT, temp))
64
68
  end
65
69
  end
66
70
 
67
71
  tar = Pkg::Tar.new
68
72
  tar.templates = templates
69
73
  tar.expand_templates
70
- tar.templates.should eq expanded_templates
74
+ expect(tar.templates).to eq(expanded_templates)
71
75
  end
72
76
  end
73
77
 
74
- describe "#template" do
78
+ describe '#template' do
75
79
  before(:each) do
76
80
  Pkg::Config.templates = expanded_templates
77
81
  end
78
82
 
79
- it "should handle hashes and strings correctly" do
80
- # Set up correct stubs and expectations
83
+ it 'should handle hashes and strings correctly' do
81
84
  expanded_templates.each do |temp|
82
- if temp.is_a?(String)
85
+ case temp
86
+ when String
83
87
  full_path_temp = File.join(PROJECT_ROOT, temp)
84
- target = full_path_temp.sub(File.extname(full_path_temp), "")
85
- elsif temp.is_a?(Hash)
86
- full_path_temp = File.join(PROJECT_ROOT, temp["source"])
87
- target = File.join(PROJECT_ROOT, temp["target"])
88
+ target = full_path_temp.sub(File.extname(full_path_temp), '')
89
+ when Hash
90
+ full_path_temp = File.join(PROJECT_ROOT, temp['source'])
91
+ target = File.join(PROJECT_ROOT, temp['target'])
88
92
  end
89
93
 
90
- Dir.stub(:glob).with(full_path_temp).and_return(full_path_temp)
91
- File.stub(:exist?).with(full_path_temp).and_return(true)
92
- Pkg::Util::File.should_receive(:erb_file).with(full_path_temp, target, true, :binding => an_instance_of(Binding))
94
+ allow(Dir).to receive(:glob).with(full_path_temp).and_return(full_path_temp)
95
+ allow(File).to receive(:exist?).with(full_path_temp).and_return(true)
96
+ expect(Pkg::Util::File)
97
+ .to receive(:erb_file)
98
+ .with(full_path_temp, target, true, binding: an_instance_of(Binding))
93
99
  end
94
100
 
95
101
  Pkg::Tar.new.template
96
102
  end
97
103
 
98
- it "should raise an error if the template source can't be found" do
99
- # Set up correct stubs and expectations
104
+ it 'should raise an error if the template source can\'t be found' do
100
105
  expanded_templates.each do |temp|
101
- if temp.is_a?(String)
102
- full_path_temp = File.join(PROJECT_ROOT, temp)
103
- target = full_path_temp.sub(File.extname(full_path_temp), "")
104
- elsif temp.is_a?(Hash)
105
- full_path_temp = File.join(PROJECT_ROOT, temp["source"])
106
- target = File.join(PROJECT_ROOT, temp["target"])
107
- end
106
+ full_path_temp = case temp
107
+ when String
108
+ File.join(PROJECT_ROOT, temp)
109
+ when Hash
110
+ File.join(PROJECT_ROOT, temp['source'])
111
+ end
108
112
 
109
- Dir.stub(:glob).with(full_path_temp).and_return(full_path_temp)
110
- File.stub(:exist?).with(full_path_temp).and_return(false)
113
+ allow(Dir).to receive(:glob).with(full_path_temp).and_return(full_path_temp)
114
+ allow(File).to receive(:exist?).with(full_path_temp).and_return(false)
111
115
  end
112
116
 
113
117
  expect { Pkg::Tar.new.template }.to raise_error RuntimeError
@@ -1,56 +1,56 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Pkg::Util::Execution" do
4
- let(:command) { "/usr/bin/do-something-important --arg1=thing2" }
5
- let(:output) { "the command returns some really cool stuff that may be useful later" }
3
+ describe 'Pkg::Util::Execution' do
4
+ let(:command) { '/usr/bin/do-something-important --arg1=thing2' }
5
+ let(:output) { 'the command returns some really cool stuff that may be useful later' }
6
6
 
7
7
  describe "#success?" do
8
- it "should return false on failure" do
9
- %x{false}
10
- Pkg::Util::Execution.success?.should be_false
8
+ it 'should return false on failure' do
9
+ %x(false)
10
+ expect(Pkg::Util::Execution.success?).to be false
11
11
  end
12
12
 
13
- it "should return true on success" do
14
- %x{true}
15
- Pkg::Util::Execution.success?.should be_true
13
+ it 'should return true on success' do
14
+ %x(true)
15
+ expect(Pkg::Util::Execution.success?).to be true
16
16
  end
17
17
 
18
- it "should return false when passed an exitstatus object from a failure" do
19
- %x{false}
20
- Pkg::Util::Execution.success?($?).should be_false
18
+ it 'should return false when passed an exitstatus object from a failure' do
19
+ %x(false)
20
+ expect(Pkg::Util::Execution.success?($?)).to be false
21
21
  end
22
22
 
23
- it "should return true when passed and exitstatus object from a success" do
24
- %x{true}
25
- Pkg::Util::Execution.success?($?).should be_true
23
+ it 'should return true when passed and exitstatus object from a success' do
24
+ %x(true)
25
+ expect(Pkg::Util::Execution.success?($?)).to be true
26
26
  end
27
27
  end
28
28
 
29
- describe "#ex" do
30
- it "should raise an error if the command fails" do
31
- Pkg::Util::Execution.should_receive(:`).with(command).and_return(true)
32
- Pkg::Util::Execution.should_receive(:success?).and_return(false)
33
- expect{ Pkg::Util::Execution.ex(command) }.to raise_error(RuntimeError)
29
+ describe '#ex' do
30
+ it 'should raise an error if the command fails' do
31
+ expect(Pkg::Util::Execution).to receive(:`).with(command).and_return(true)
32
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(false)
33
+ expect { Pkg::Util::Execution.ex(command) }.to raise_error(RuntimeError)
34
34
  end
35
35
 
36
- it "should return the output of the command for success" do
37
- Pkg::Util::Execution.should_receive(:`).with(command).and_return(output)
38
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
39
- Pkg::Util::Execution.ex(command).should == output
36
+ it 'should return the output of the command for success' do
37
+ expect(Pkg::Util::Execution).to receive(:`).with(command).and_return(output)
38
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
39
+ expect(Pkg::Util::Execution.ex(command)).to eq output
40
40
  end
41
41
  end
42
42
 
43
- describe "#capture3" do
44
- it "should raise an error if the command fails" do
45
- Open3.should_receive(:capture3).with(command).and_return([output, '', 1])
46
- Pkg::Util::Execution.should_receive(:success?).with(1).and_return(false)
47
- expect{ Pkg::Util::Execution.capture3(command) }.to raise_error(RuntimeError, /#{output}/)
43
+ describe '#capture3' do
44
+ it 'should raise an error if the command fails' do
45
+ expect(Open3).to receive(:capture3).with(command).and_return([output, '', 1])
46
+ expect(Pkg::Util::Execution).to receive(:success?).with(1).and_return(false)
47
+ expect { Pkg::Util::Execution.capture3(command) }.to raise_error(RuntimeError, /#{output}/)
48
48
  end
49
49
 
50
50
  it "should return the output of the command for success" do
51
- Open3.should_receive(:capture3).with(command).and_return([output, '', 0])
52
- Pkg::Util::Execution.should_receive(:success?).with(0).and_return(true)
53
- Pkg::Util::Execution.capture3(command).should == [output, '', 0]
51
+ expect(Open3).to receive(:capture3).with(command).and_return([output, '', 0])
52
+ expect(Pkg::Util::Execution).to receive(:success?).with(0).and_return(true)
53
+ expect(Pkg::Util::Execution.capture3(command)).to eq([output, '', 0])
54
54
  end
55
55
  end
56
56
  end