packaging 0.108.2 → 0.109.0

Sign up to get free protection for your applications and to get access to all the features.
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,255 +2,296 @@ require 'spec_helper'
2
2
  require 'socket'
3
3
  require 'open3'
4
4
 
5
- describe "Pkg::Util::Net" do
6
- let(:target) { "/tmp/placething" }
7
- let(:target_uri) { "http://google.com" }
8
- let(:content) { "stuff" }
9
- let(:rsync) { "/bin/rsync" }
10
- let(:ssh) { "/usr/local/bin/ssh" }
11
- let(:s3cmd) { "/usr/local/bin/s3cmd" }
12
-
13
- describe "#fetch_uri" do
14
- context "given a target directory" do
15
- it "does nothing if the directory isn't writable" do
16
- File.stub(:writable?).with(File.dirname(target)) { false }
17
- File.should_receive(:open).never
5
+ describe 'Pkg::Util::Net' do
6
+ let(:target) { '/tmp/placething' }
7
+ let(:target_uri) { 'http://google.com' }
8
+ let(:content) { 'stuff' }
9
+ let(:rsync) { '/bin/rsync' }
10
+ let(:ssh) { '/usr/local/bin/ssh' }
11
+ let(:s3cmd) { '/usr/local/bin/s3cmd' }
12
+
13
+ describe '#fetch_uri' do
14
+ context 'given a target directory' do
15
+ it 'does nothing if the directory isn\'t writable' do
16
+ allow(File).to receive(:writable?).with(File.dirname(target)).and_return(false)
17
+ expect(File).not_to receive(:open)
18
18
  Pkg::Util::Net.fetch_uri(target_uri, target)
19
19
  end
20
20
 
21
- it "writes the content of the uri to a file if directory is writable" do
22
- File.should_receive(:writable?).once.with(File.dirname(target)) { true }
23
- File.should_receive(:open).once.with(target, 'w')
21
+ it 'writes the content of the uri to a file if directory is writable' do
22
+ expect(File).to receive(:writable?).once.with(File.dirname(target)) { true }
23
+ expect(File).to receive(:open).once.with(target, 'w')
24
24
  Pkg::Util::Net.fetch_uri(target_uri, target)
25
25
  end
26
26
  end
27
27
  end
28
28
 
29
- describe "hostname utils" do
30
-
31
- describe "hostname" do
32
- it "should return the hostname of the current host" do
33
- Socket.stub(:gethostname) { "foo" }
34
- Pkg::Util::Net.hostname.should eq("foo")
29
+ describe 'hostname utils' do
30
+ describe 'hostname' do
31
+ it 'should return the hostname of the current host' do
32
+ allow(Socket).to receive(:gethostname).and_return('foo')
33
+ expect(Pkg::Util::Net.hostname).to eq('foo')
35
34
  end
36
35
  end
37
36
 
38
- describe "check_host" do
39
- context "with required :true" do
40
- it "should raise an exception if the passed host does not match the current host" do
41
- Socket.stub(:gethostname) { "foo" }
42
- Pkg::Util::Net.should_receive(:check_host).and_raise(RuntimeError)
43
- expect{ Pkg::Util::Net.check_host("bar", :required => true) }.to raise_error(RuntimeError)
37
+ describe 'check_host' do
38
+ context 'with required :true' do
39
+ it 'should raise an exception if the passed host does not match the current host' do
40
+ allow(Socket).to receive(:gethostname).and_return('foo')
41
+ expect(Pkg::Util::Net).to receive(:check_host).and_raise(RuntimeError)
42
+ expect { Pkg::Util::Net.check_host('bar', required: true) }.to raise_error(RuntimeError)
44
43
  end
45
44
  end
46
45
 
47
- context "with required :false" do
48
- it "should return nil if the passed host does not match the current host" do
49
- Socket.stub(:gethostname) { "foo" }
50
- Pkg::Util::Net.check_host("bar", :required => false).should be_nil
46
+ context 'with required :false' do
47
+ it 'should return nil if the passed host does not match the current host' do
48
+ allow(Socket).to receive(:gethostname).and_return('foo')
49
+ expect(Pkg::Util::Net.check_host('bar', required: false)).to be_nil
51
50
  end
52
51
  end
53
52
  end
54
53
  end
55
54
 
56
- describe "remote_ssh_cmd" do
57
- it "should be able to call via deprecated shim" do
58
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
59
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
60
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
61
- Pkg::Util::Net.remote_ssh_cmd("foo", "bar", true)
55
+ describe 'remote_ssh_cmd' do
56
+ it 'should be able to call via deprecated shim' do
57
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_return(ssh)
58
+ expect(Pkg::Util::Execution).to receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
59
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
60
+ Pkg::Util::Net.remote_ssh_cmd('foo', 'bar', true)
62
61
  end
63
62
  end
64
63
 
65
- describe "remote_execute" do
66
- it "should fail if ssh is not present" do
67
- Pkg::Util::Tool.stub(:find_tool).with("ssh") { fail }
68
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_raise(RuntimeError)
69
- expect{ Pkg::Util::Net.remote_execute("foo", "bar") }.to raise_error(RuntimeError)
64
+ describe 'remote_execute' do
65
+ it 'should fail if ssh is not present' do
66
+ allow(Pkg::Util::Tool).to receive(:find_tool).with('ssh').and_raise(RuntimeError)
67
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_raise(RuntimeError)
68
+ expect { Pkg::Util::Net.remote_execute('foo', 'bar') }.to raise_error(RuntimeError)
70
69
  end
71
70
 
72
- it "should be able to not fail fast" do
73
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
74
- Kernel.should_receive(:system).with("#{ssh} -t foo 'bar'")
75
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
76
- Pkg::Util::Net.remote_execute(
77
- "foo", "bar", capture_output: false, extra_options: '', fail_fast: false)
71
+ it 'should be able to not fail fast' do
72
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_return(ssh)
73
+ expect(Kernel).to receive(:system).with("#{ssh} -t foo 'bar'")
74
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
75
+ Pkg::Util::Net.remote_execute(
76
+ 'foo', 'bar', capture_output: false, extra_options: '', fail_fast: false
77
+ )
78
78
  end
79
79
 
80
- it "should be able to trace output" do
81
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
82
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -x;bar'")
83
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
84
- Pkg::Util::Net.remote_execute(
85
- "foo", "bar", capture_output: false, fail_fast: false, trace: true)
80
+ it 'should be able to trace output' do
81
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_return(ssh)
82
+ expect(Kernel).to receive(:system).with("#{ssh} -t foo 'set -x;bar'")
83
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
84
+ Pkg::Util::Net.remote_execute(
85
+ 'foo', 'bar', capture_output: false, fail_fast: false, trace: true
86
+ )
86
87
  end
87
88
 
88
- context "without output captured" do
89
- it "should execute a command :foo on a host :bar using Kernel" do
90
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
91
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e;bar'")
92
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
93
- Pkg::Util::Net.remote_execute("foo", "bar")
89
+ context 'without output captured' do
90
+ it 'should execute a command :foo on a host :bar using Kernel' do
91
+ expect(Pkg::Util::Tool).to receive(:check_tool).with("ssh").and_return(ssh)
92
+ expect(Kernel).to receive(:system).with("#{ssh} -t foo 'set -e;bar'")
93
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
94
+ Pkg::Util::Net.remote_execute('foo', 'bar')
94
95
  end
95
96
 
96
- it "should escape single quotes in the command" do
97
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
98
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e;b'\\''ar'")
99
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
100
- Pkg::Util::Net.remote_execute("foo", "b'ar")
97
+ it 'should escape single quotes in the command' do
98
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_return(ssh)
99
+ expect(Kernel).to receive(:system).with("#{ssh} -t foo 'set -e;b'\\''ar'")
100
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
101
+ Pkg::Util::Net.remote_execute('foo', "b'ar")
101
102
  end
102
103
 
103
- it "should raise an error if ssh fails" do
104
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
105
- Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e;bar'")
106
- Pkg::Util::Execution.should_receive(:success?).and_return(false)
107
- expect{ Pkg::Util::Net.remote_execute("foo", "bar") }
104
+ it 'should raise an error if ssh fails' do
105
+ expect(Pkg::Util::Tool).to receive(:check_tool).with("ssh").and_return(ssh)
106
+ expect(Kernel).to receive(:system).with("#{ssh} -t foo 'set -e;bar'")
107
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(false)
108
+ expect { Pkg::Util::Net.remote_execute('foo', 'bar') }
108
109
  .to raise_error(RuntimeError, /failed./)
109
110
  end
110
111
  end
111
112
 
112
- context "with output captured" do
113
- it "should execute a command :foo on a host :bar using Pkg::Util::Execution.capture3" do
114
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
115
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
116
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
117
- Pkg::Util::Net.remote_execute("foo", "bar", capture_output: true)
113
+ context 'with output captured' do
114
+ it 'should execute a command :foo on a host :bar using Pkg::Util::Execution.capture3' do
115
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_return(ssh)
116
+ expect(Pkg::Util::Execution).to receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
117
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
118
+ Pkg::Util::Net.remote_execute('foo', 'bar', capture_output: true)
118
119
  end
119
120
 
120
121
  it "should escape single quotes in the command" do
121
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
122
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;b'\\''ar'")
123
- Pkg::Util::Execution.should_receive(:success?).and_return(true)
124
- Pkg::Util::Net.remote_execute("foo", "b'ar", capture_output: true)
122
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_return(ssh)
123
+ expect(Pkg::Util::Execution).to receive(:capture3).with("#{ssh} -t foo 'set -e;b'\\''ar'")
124
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(true)
125
+ Pkg::Util::Net.remote_execute('foo', "b'ar", capture_output: true)
125
126
  end
126
127
 
127
128
  it "should raise an error if ssh fails" do
128
- Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh)
129
- Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
130
- Pkg::Util::Execution.should_receive(:success?).and_return(false)
131
- expect{ Pkg::Util::Net.remote_execute("foo", "bar", capture_output: true) }
129
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('ssh').and_return(ssh)
130
+ expect(Pkg::Util::Execution).to receive(:capture3).with("#{ssh} -t foo 'set -e;bar'")
131
+ expect(Pkg::Util::Execution).to receive(:success?).and_return(false)
132
+ expect { Pkg::Util::Net.remote_execute('foo', 'bar', capture_output: true) }
132
133
  .to raise_error(RuntimeError, /failed./)
133
134
  end
134
135
  end
135
136
  end
136
137
 
137
- describe "#rsync_to" do
138
- defaults = "--recursive --hard-links --links --verbose --omit-dir-times --no-perms --no-owner --no-group"
139
- it "should fail if rsync is not present" do
140
- Pkg::Util::Tool.stub(:find_tool).with("rsync") { fail }
141
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_raise(RuntimeError)
142
- expect{ Pkg::Util::Net.rsync_to("foo", "bar", "boo") }.to raise_error(RuntimeError)
138
+ describe '#rsync_to' do
139
+ defaults = '--recursive --hard-links --links --verbose --omit-dir-times --no-perms --no-owner --no-group'
140
+ it 'should fail if rsync is not present' do
141
+ allow(Pkg::Util::Tool).to receive(:find_tool).with('rsync').and_raise(RuntimeError)
142
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_raise(RuntimeError)
143
+ expect { Pkg::Util::Net.rsync_to('foo', 'bar', 'boo') }.to raise_error(RuntimeError)
143
144
  end
144
145
 
145
146
  it "should rsync 'thing' to 'foo@bar:/home/foo' with flags '#{defaults} --ignore-existing'" do
146
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
147
- Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} --ignore-existing thing foo@bar:/home/foo", true)
148
- Pkg::Util::Net.rsync_to("thing", "foo@bar", "/home/foo")
147
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_return(rsync)
148
+ expect(Pkg::Util::Execution)
149
+ .to receive(:capture3)
150
+ .with("#{rsync} #{defaults} --ignore-existing thing foo@bar:/home/foo", true)
151
+ Pkg::Util::Net.rsync_to('thing', 'foo@bar', '/home/foo')
149
152
  end
150
153
 
151
154
  it "rsyncs 'thing' to 'foo@bar:/home/foo' with flags that don't include --ignore-existing" do
152
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
153
- Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} thing foo@bar:/home/foo", true)
154
- Pkg::Util::Net.rsync_to("thing", "foo@bar", "/home/foo", extra_flags: [])
155
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_return(rsync)
156
+ expect(Pkg::Util::Execution)
157
+ .to receive(:capture3)
158
+ .with("#{rsync} #{defaults} thing foo@bar:/home/foo", true)
159
+ Pkg::Util::Net.rsync_to('thing', 'foo@bar', '/home/foo', extra_flags: [])
155
160
  end
156
161
 
157
162
  it "rsyncs 'thing' to 'foo@bar:/home/foo' with flags that don't include arbitrary flags" do
158
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
159
- Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} --foo-bar --and-another-flag thing foo@bar:/home/foo", true)
160
- Pkg::Util::Net.rsync_to("thing", "foo@bar", "/home/foo", extra_flags: ["--foo-bar", "--and-another-flag"])
163
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_return(rsync)
164
+ expect(Pkg::Util::Execution)
165
+ .to receive(:capture3)
166
+ .with("#{rsync} #{defaults} --foo-bar --and-another-flag thing foo@bar:/home/foo", true)
167
+ Pkg::Util::Net.rsync_to('thing', 'foo@bar', '/home/foo',
168
+ extra_flags: ["--foo-bar", "--and-another-flag"])
161
169
  end
162
170
  end
163
171
 
164
- describe "#s3sync_to" do
165
- it "should fail if s3cmd is not present" do
166
- Pkg::Util::Tool.should_receive(:find_tool).with('s3cmd', :required => true).and_raise(RuntimeError)
167
- Pkg::Util::Execution.should_not_receive(:capture3).with("#{s3cmd} sync 'foo' s3://bar/boo/")
168
- expect{ Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError)
172
+ describe '#s3sync_to' do
173
+ it 'should fail if s3cmd is not present' do
174
+ expect(Pkg::Util::Tool)
175
+ .to receive(:find_tool)
176
+ .with('s3cmd', required: true)
177
+ .and_raise(RuntimeError)
178
+ expect(Pkg::Util::Execution)
179
+ .to_not receive(:capture3).with("#{s3cmd} sync 'foo' s3://bar/boo/")
180
+ expect { Pkg::Util::Net.s3sync_to('foo', 'bar', 'boo') }.to raise_error(RuntimeError)
169
181
  end
170
182
 
171
- it "should fail if ~/.s3cfg is not present" do
172
- Pkg::Util::Tool.should_receive(:check_tool).with("s3cmd").and_return(s3cmd)
173
- Pkg::Util::File.should_receive(:file_exists?).with(File.join(ENV['HOME'], '.s3cfg')).and_return(false)
174
- expect{ Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError, /does not exist/)
183
+ it 'should fail if ~/.s3cfg is not present' do
184
+ expect(Pkg::Util::Tool).to receive(:check_tool).with("s3cmd").and_return(s3cmd)
185
+ expect(Pkg::Util::File)
186
+ .to receive(:file_exists?)
187
+ .with(File.join(ENV['HOME'], '.s3cfg'))
188
+ .and_return(false)
189
+ expect { Pkg::Util::Net.s3sync_to('foo', 'bar', 'boo') }
190
+ .to raise_error(RuntimeError, /does not exist/)
175
191
  end
176
192
 
177
193
  it "should s3 sync 'thing' to 's3://foo@bar/home/foo/' with no flags" do
178
- Pkg::Util::Tool.should_receive(:check_tool).with("s3cmd").and_return(s3cmd)
179
- Pkg::Util::File.should_receive(:file_exists?).with(File.join(ENV['HOME'], '.s3cfg')).and_return(true)
180
- Pkg::Util::Execution.should_receive(:capture3).with("#{s3cmd} sync 'thing' s3://foo@bar/home/foo/")
194
+ expect(Pkg::Util::Tool).to receive(:check_tool).with("s3cmd").and_return(s3cmd)
195
+ expect(Pkg::Util::File)
196
+ .to receive(:file_exists?)
197
+ .with(File.join(ENV['HOME'], '.s3cfg'))
198
+ .and_return(true)
199
+ expect(Pkg::Util::Execution)
200
+ .to receive(:capture3)
201
+ .with("#{s3cmd} sync 'thing' s3://foo@bar/home/foo/")
181
202
  Pkg::Util::Net.s3sync_to("thing", "foo@bar", "home/foo")
182
203
  end
183
204
 
184
- it "should s3 sync 'thing' to 's3://foo@bar/home/foo/' with --delete-removed and --acl-public" do
185
- Pkg::Util::Tool.should_receive(:check_tool).with("s3cmd").and_return(s3cmd)
186
- Pkg::Util::File.should_receive(:file_exists?).with(File.join(ENV['HOME'], '.s3cfg')).and_return(true)
187
- Pkg::Util::Execution.should_receive(:capture3).with("#{s3cmd} sync --delete-removed --acl-public 'thing' s3://foo@bar/home/foo/")
205
+ it "should s3sync 'thing' to 's3://foo@bar/home/foo/' with --delete-removed and --acl-public" do
206
+ expect(Pkg::Util::Tool).to receive(:check_tool).with("s3cmd").and_return(s3cmd)
207
+ expect(Pkg::Util::File)
208
+ .to receive(:file_exists?)
209
+ .with(File.join(ENV['HOME'], '.s3cfg'))
210
+ .and_return(true)
211
+ expect(Pkg::Util::Execution)
212
+ .to receive(:capture3)
213
+ .with("#{s3cmd} sync --delete-removed --acl-public 'thing' s3://foo@bar/home/foo/")
188
214
  Pkg::Util::Net.s3sync_to("thing", "foo@bar", "home/foo", ["--delete-removed", "--acl-public"])
189
215
  end
190
216
  end
191
217
 
192
- describe "#rsync_from" do
218
+ describe '#rsync_from' do
193
219
  defaults = "--recursive --hard-links --links --verbose --omit-dir-times --no-perms --no-owner --no-group"
194
- it "should fail if rsync is not present" do
195
- Pkg::Util::Tool.stub(:find_tool).with("rsync") { fail }
196
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_raise(RuntimeError)
197
- expect{ Pkg::Util::Net.rsync_from("foo", "bar", "boo") }.to raise_error(RuntimeError)
220
+ it 'should fail if rsync is not present' do
221
+ allow(Pkg::Util::Tool).to receive(:find_tool).with('rsync').and_raise(RuntimeError)
222
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_raise(RuntimeError)
223
+ expect { Pkg::Util::Net.rsync_from('foo', 'bar', 'boo') }.to raise_error(RuntimeError)
198
224
  end
199
225
 
200
- it "should not include the flags '--ignore-existing' by default" do
201
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
202
- Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} foo@bar:thing /home/foo", true)
203
- Pkg::Util::Net.rsync_from("thing", "foo@bar", "/home/foo")
226
+ it 'should not include the flags \'--ignore-existing\' by default' do
227
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_return(rsync)
228
+ expect(Pkg::Util::Execution)
229
+ .to receive(:capture3)
230
+ .with("#{rsync} #{defaults} foo@bar:thing /home/foo", true)
231
+ Pkg::Util::Net.rsync_from('thing', 'foo@bar', '/home/foo')
204
232
  end
205
233
 
206
234
  it "should rsync 'thing' from 'foo@bar' to '/home/foo' with flags '#{defaults}'" do
207
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
208
- Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} foo@bar:thing /home/foo", true)
209
- Pkg::Util::Net.rsync_from("thing", "foo@bar", "/home/foo")
235
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_return(rsync)
236
+ expect(Pkg::Util::Execution)
237
+ .to receive(:capture3)
238
+ .with("#{rsync} #{defaults} foo@bar:thing /home/foo", true)
239
+ Pkg::Util::Net.rsync_from('thing', 'foo@bar', '/home/foo')
210
240
  end
211
241
 
212
242
  it "rsyncs 'thing' from 'foo@bar:/home/foo' with flags that don't include arbitrary flags" do
213
- Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_return(rsync)
214
- Pkg::Util::Execution.should_receive(:capture3).with("#{rsync} #{defaults} --foo-bar --and-another-flag foo@bar:thing /home/foo", true)
215
- Pkg::Util::Net.rsync_from("thing", "foo@bar", "/home/foo", extra_flags: ["--foo-bar", "--and-another-flag"])
243
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('rsync').and_return(rsync)
244
+ expect(Pkg::Util::Execution)
245
+ .to receive(:capture3)
246
+ .with("#{rsync} #{defaults} --foo-bar --and-another-flag foo@bar:thing /home/foo", true)
247
+ Pkg::Util::Net.rsync_from('thing', 'foo@bar', '/home/foo',
248
+ extra_flags: ['--foo-bar', '--and-another-flag'])
216
249
  end
217
250
  end
218
251
 
219
252
  describe "#curl_form_data" do
220
- let(:curl) {"/bin/curl"}
221
- let(:form_data) {["name=FOO"]}
222
- let(:options) { {:quiet => true} }
223
-
224
- it "should return false on failure" do
225
- Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
226
- Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i '#{target_uri}'").and_return(['stdout', 'stderr', 1])
227
- Pkg::Util::Net.curl_form_data(target_uri).should eq(['stdout', 1])
253
+ let(:curl) { '/bin/curl' }
254
+ let(:form_data) { ['name=FOO'] }
255
+ let(:options) { { quiet: true } }
256
+
257
+ it 'should return false on failure' do
258
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('curl').and_return(curl)
259
+ expect(Pkg::Util::Execution)
260
+ .to receive(:capture3)
261
+ .with("#{curl} -i '#{target_uri}'").and_return(['stdout', 'stderr', 1])
262
+ expect(Pkg::Util::Net.curl_form_data(target_uri)).to eq(['stdout', 1])
228
263
  end
229
264
 
230
265
 
231
266
  it "should curl with just the uri" do
232
- Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
233
- Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i '#{target_uri}'")
267
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('curl').and_return(curl)
268
+ expect(Pkg::Util::Execution).to receive(:capture3).with("#{curl} -i '#{target_uri}'")
234
269
  Pkg::Util::Net.curl_form_data(target_uri)
235
270
  end
236
271
 
237
- it "should curl with the form data and uri" do
238
- Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
239
- Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i #{form_data[0]} '#{target_uri}'")
272
+ it 'should curl with the form data and uri' do
273
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('curl').and_return(curl)
274
+ expect(Pkg::Util::Execution)
275
+ .to receive(:capture3)
276
+ .with("#{curl} -i #{form_data[0]} '#{target_uri}'")
240
277
  Pkg::Util::Net.curl_form_data(target_uri, form_data)
241
278
  end
242
279
 
243
- it "should curl with form data, uri, and be quiet" do
244
- Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl)
245
- Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i #{form_data[0]} '#{target_uri}'").and_return(['stdout', 'stderr', 0])
246
- Pkg::Util::Net.curl_form_data(target_uri, form_data, options).should eq(['', 0])
280
+ it 'should curl with form data, uri, and be quiet' do
281
+ expect(Pkg::Util::Tool).to receive(:check_tool).with('curl').and_return(curl)
282
+ expect(Pkg::Util::Execution)
283
+ .to receive(:capture3)
284
+ .with("#{curl} -i #{form_data[0]} '#{target_uri}'")
285
+ .and_return(['stdout', 'stderr', 0])
286
+ expect(Pkg::Util::Net.curl_form_data(target_uri, form_data, options)).to eq(['', 0])
247
287
  end
248
-
249
288
  end
250
289
 
251
- describe "#print_url_info" do
252
- it "should output correct formatting" do
253
- Pkg::Util::Net.should_receive(:puts).with("\n////////////////////////////////////////////////////////////////////////////////\n\n
290
+ describe '#print_url_info' do
291
+ it 'should output correct formatting' do
292
+ expect(Pkg::Util::Net)
293
+ .to receive(:puts)
294
+ .with("\n////////////////////////////////////////////////////////////////////////////////\n\n
254
295
  Build submitted. To view your build progress, go to\n#{target_uri}\n\n
255
296
  ////////////////////////////////////////////////////////////////////////////////\n\n")
256
297
  Pkg::Util::Net.print_url_info(target_uri)
@@ -1,10 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Pkg::Util::RakeUtils" do
3
+ describe 'Pkg::Util::RakeUtils' do
4
4
  let(:foo_defined?) { Rake::Task.task_defined?(:foo) }
5
5
  let(:bar_defined?) { Rake::Task.task_defined?(:bar) }
6
- let(:define_foo) { body = proc{}; Rake::Task.define_task(:foo, &body) }
7
- let(:define_bar) { body = proc{}; Rake::Task.define_task(:bar, &body) }
6
+ let(:define_foo) do
7
+ body = proc {}
8
+ Rake::Task.define_task(:foo, &body)
9
+ end
10
+ let(:define_bar) do
11
+ body = proc {}
12
+ Rake::Task.define_task(:bar, &body)
13
+ end
8
14
 
9
15
  before(:each) do
10
16
  if foo_defined?
@@ -12,21 +18,21 @@ describe "Pkg::Util::RakeUtils" do
12
18
  end
13
19
  end
14
20
 
15
- describe "#task_defined?" do
16
- context "given a Rake::Task task name" do
17
- it "should return true if the task exists" do
18
- Rake::Task.stub(:task_defined?).with(:foo) {true}
19
- expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_true
21
+ describe '#task_defined?' do
22
+ context 'given a Rake::Task task name' do
23
+ it 'should return true if the task exists' do
24
+ allow(Rake::Task).to receive(:task_defined?).with(:foo).and_return(true)
25
+ expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be true
20
26
  end
21
- it "should return false if the task does not exist" do
22
- Rake::Task.stub(:task_defined?).with(:foo) {false}
23
- expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be_false
27
+ it 'should return false if the task does not exist' do
28
+ allow(Rake::Task).to receive(:task_defined?).with(:foo).and_return(false)
29
+ expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be false
24
30
  end
25
31
  end
26
32
  end
27
33
 
28
- describe "#get_task" do
29
- it "should return a task object for a named task" do
34
+ describe '#get_task' do
35
+ it 'should return a task object for a named task' do
30
36
  foo = nil
31
37
  if !foo_defined?
32
38
  foo = define_foo
@@ -39,8 +45,8 @@ describe "Pkg::Util::RakeUtils" do
39
45
  end
40
46
  end
41
47
 
42
- describe "#add_dependency" do
43
- it "should add a dependency to a given rake task" do
48
+ describe '#add_dependency' do
49
+ it 'should add a dependency to a given rake task' do
44
50
  foo = nil
45
51
  bar = nil
46
52
  if !foo_defined?
@@ -58,9 +64,9 @@ describe "Pkg::Util::RakeUtils" do
58
64
  end
59
65
  end
60
66
 
61
- describe "#evaluate_pre_tasks" do
62
- context "Given a data file with :pre_tasks defined" do
63
- it "should, for each k=>v pair, add v as a dependency to k" do
67
+ describe '#evaluate_pre_tasks' do
68
+ context 'Given a data file with :pre_tasks defined' do
69
+ it 'should, for each k=>v pair, add v as a dependency to k' do
64
70
  Pkg::Config.config_from_yaml(File.join(FIXTURES, 'util', 'pre_tasks.yaml'))
65
71
  expect(Pkg::Util::RakeUtils).to receive(:add_dependency)
66
72
  Pkg::Util::RakeUtils.evaluate_pre_tasks
@@ -2,18 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  # We load packaging.rb once, in spec_helper, to avoid reloading the library
4
4
  # and issuing warnings about already defined constants.
5
- describe "Pkg" do
6
- it "should require the utilities module, Pkg::Util" do
7
- Pkg::Util.should_not be_nil
5
+ describe 'Pkg' do
6
+ it 'should require the utilities module, Pkg::Util' do
7
+ expect(Pkg::Util).to_not be_nil
8
8
  end
9
9
 
10
- it "should require the configuration module, Pkg::Config" do
11
- Pkg::Config.should_not be_nil
10
+ it 'should require the configuration module, Pkg::Config' do
11
+ expect(Pkg::Config).to_not be_nil
12
12
  end
13
13
 
14
- it "should require the tar library, Pkg::Tar" do
15
- Pkg::Tar.should_not be_nil
14
+ it 'should require the tar library, Pkg::Tar' do
15
+ expect(Pkg::Tar).to_not be_nil
16
16
  end
17
-
18
17
  end
19
-
data/tasks/apple.rake CHANGED
@@ -57,19 +57,19 @@ def make_directory_tree
57
57
  mkdir_p(val)
58
58
  end
59
59
 
60
- if File.exists?('ext/osx/postflight.erb')
60
+ if File.exist?('ext/osx/postflight.erb')
61
61
  Pkg::Util::File.erb_file 'ext/osx/postflight.erb', "#{@working_tree['scripts']}/postinstall", false, :binding => binding
62
62
  end
63
63
 
64
- if File.exists?('ext/osx/preflight.erb')
64
+ if File.exist?('ext/osx/preflight.erb')
65
65
  Pkg::Util::File.erb_file 'ext/osx/preflight.erb', "#{@working_tree['scripts']}/preinstall", false, :binding => binding
66
66
  end
67
67
 
68
- if File.exists?('ext/osx/prototype.plist.erb')
68
+ if File.exist?('ext/osx/prototype.plist.erb')
69
69
  Pkg::Util::File.erb_file 'ext/osx/prototype.plist.erb', "#{@scratch}/prototype.plist", false, :binding => binding
70
70
  end
71
71
 
72
- if File.exists?('ext/packaging/static_artifacts/PackageInfo.plist')
72
+ if File.exist?('ext/packaging/static_artifacts/PackageInfo.plist')
73
73
  cp 'ext/packaging/static_artifacts/PackageInfo.plist', "#{@scratch}/PackageInfo.plist"
74
74
  end
75
75
  end
@@ -148,13 +148,13 @@ def pack_source
148
148
 
149
149
  # Setup a preinstall script and replace variables in the files with
150
150
  # the correct paths.
151
- if File.exists?("#{@working_tree['scripts']}/preinstall")
151
+ if File.exist?("#{@working_tree['scripts']}/preinstall")
152
152
  chmod(0755, "#{@working_tree['scripts']}/preinstall")
153
153
  sh "sudo chown root:wheel #{@working_tree['scripts']}/preinstall"
154
154
  end
155
155
 
156
156
  # Setup a postinstall from from the erb created earlier
157
- if File.exists?("#{@working_tree['scripts']}/postinstall")
157
+ if File.exist?("#{@working_tree['scripts']}/postinstall")
158
158
  chmod(0755, "#{@working_tree['scripts']}/postinstall")
159
159
  sh "sudo chown root:wheel #{@working_tree['scripts']}/postinstall"
160
160
  end
@@ -244,8 +244,7 @@ namespace :package do
244
244
  if Pkg::Config.build_dmg
245
245
  bench = Benchmark.realtime do
246
246
  # Test for pkgbuild binary
247
- fail "pkgbuild must be installed." unless \
248
- File.exists?(PKGBUILD)
247
+ fail "pkgbuild must be installed." unless File.exist?(PKGBUILD)
249
248
 
250
249
  make_directory_tree
251
250
  pack_source
data/tasks/deb.rake CHANGED
@@ -52,7 +52,7 @@ task :prep_deb_tars, :work_dir do |t, args|
52
52
  elsif file.directory?
53
53
  mkdir_p "#{pkg_dir}/#{file}"
54
54
  elsif file.extname == '.erb'
55
- Pkg::Util::File.erb_file(file, "#{pkg_dir}/#{file.sub(/\.[^\.]*$/, '')}", false, :binding => Pkg::Config.get_binding)
55
+ Pkg::Util::File.erb_file(file, "#{pkg_dir}/#{file.sub(/\.[^.]*$/, '')}", false, :binding => Pkg::Config.get_binding)
56
56
  else
57
57
  cp file, "#{pkg_dir}/#{file}"
58
58
  end