cartage 2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_cartage.rb CHANGED
@@ -1,91 +1,91 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'minitest_config'
3
+ require "minitest_config"
4
4
 
5
5
  describe Cartage do
6
6
  let(:config) { nil }
7
7
  let(:cartage) { Cartage.new(config) }
8
8
 
9
- describe '#initialize' do
10
- it 'loads an empty configuration when created without a config' do
9
+ describe "#initialize" do
10
+ it "loads an empty configuration when created without a config" do
11
11
  assert_equal Cartage::Config.new, cartage.config
12
12
  end
13
13
  end
14
14
 
15
- describe '#name, #name=' do
16
- it 'defaults to #default_name' do
15
+ describe "#name, #name=" do
16
+ it "defaults to #default_name" do
17
17
  stub_cartage_repo_url do
18
- assert_equal 'repo-url', cartage.name
18
+ assert_equal "repo-url", cartage.name
19
19
  assert_equal cartage.default_name, cartage.name
20
20
  end
21
21
  end
22
22
 
23
- it 'can be overridden' do
23
+ it "can be overridden" do
24
24
  stub_cartage_repo_url do
25
- cartage.name = 'xyz'
26
- assert_equal 'xyz', cartage.name
25
+ cartage.name = "xyz"
26
+ assert_equal "xyz", cartage.name
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
- describe '#root_path, #root_path=' do
32
- it 'defaults to #default_root_path' do
31
+ describe "#root_path, #root_path=" do
32
+ it "defaults to #default_root_path" do
33
33
  stub_cartage_repo_url do
34
- stub_backticks '/x/y/z' do
35
- assert_equal Pathname('/x/y/z'), cartage.root_path
34
+ stub_backticks "/x/y/z" do
35
+ assert_equal Pathname("/x/y/z"), cartage.root_path
36
36
  assert_equal cartage.default_root_path, cartage.root_path
37
37
  end
38
38
  end
39
39
  end
40
40
 
41
- it 'can be overridden and creates a Pathname' do
41
+ it "can be overridden and creates a Pathname" do
42
42
  stub_cartage_repo_url do
43
- cartage.root_path = '/a/b/c'
44
- assert_equal Pathname('/a/b/c'), cartage.root_path
43
+ cartage.root_path = "/a/b/c"
44
+ assert_equal Pathname("/a/b/c"), cartage.root_path
45
45
  end
46
46
  end
47
47
 
48
- it 'expands the created Pathname' do
48
+ it "expands the created Pathname" do
49
49
  stub_cartage_repo_url do
50
- cartage.root_path = '/a/b/../c'
51
- assert_equal Pathname('/a/c'), cartage.root_path
50
+ cartage.root_path = "/a/b/../c"
51
+ assert_equal Pathname("/a/c"), cartage.root_path
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
- describe '#timestamp, #timestamp=' do
56
+ describe "#timestamp, #timestamp=" do
57
57
  it 'defaults to #now.utc.strftime("%Y%m%d%H%M%S")' do
58
- stub Time, :now, -> { Time.new(2014, 12, 31, 23, 59, 59, '+00:00') } do
59
- assert_equal '20141231235959', cartage.timestamp
58
+ stub Time, :now, -> { Time.new(2014, 12, 31, 23, 59, 59, "+00:00") } do
59
+ assert_equal "20141231235959", cartage.timestamp
60
60
  assert_equal cartage.default_timestamp, cartage.timestamp
61
61
  end
62
62
  end
63
63
 
64
- it 'does no validation of assigned values' do
65
- cartage.timestamp = 'not a timestamp'
66
- assert_equal 'not a timestamp', cartage.timestamp
64
+ it "does no validation of assigned values" do
65
+ cartage.timestamp = "not a timestamp"
66
+ assert_equal "not a timestamp", cartage.timestamp
67
67
  end
68
68
  end
69
69
 
70
- describe '#target, #target=' do
71
- it 'defaults to tmp/ as a Pathname' do
72
- assert_equal Pathname('tmp'), cartage.target
70
+ describe "#target, #target=" do
71
+ it "defaults to tmp/ as a Pathname" do
72
+ assert_equal Pathname("tmp"), cartage.target
73
73
  assert_equal cartage.default_target, cartage.target
74
74
  end
75
75
 
76
- it 'it converts the assigned value into a pathname' do
77
- cartage.target = '/a/b/c'
78
- assert_equal Pathname('/a/b/c'), cartage.target
76
+ it "it converts the assigned value into a pathname" do
77
+ cartage.target = "/a/b/c"
78
+ assert_equal Pathname("/a/b/c"), cartage.target
79
79
  end
80
80
  end
81
81
 
82
- describe '#compression, #compression=' do
83
- it 'defaults to :bzip2' do
82
+ describe "#compression, #compression=" do
83
+ it "defaults to :bzip2" do
84
84
  assert_equal :bzip2, cartage.compression
85
85
  end
86
86
 
87
- it 'accepts bzip2, none, and gzip as valid values' do
88
- candidates = %i(bzip2 none gzip)
87
+ it "accepts bzip2, none, and gzip as valid values" do
88
+ candidates = %i[bzip2 none gzip]
89
89
  candidates += candidates.map(&:to_s)
90
90
  candidates.each { |candidate|
91
91
  cartage.compression = candidate
@@ -93,68 +93,68 @@ describe Cartage do
93
93
  }
94
94
  end
95
95
 
96
- it 'fails if given an unknown type' do
97
- assert_raises_with_message ArgumentError, 'Invalid compression type nil' do
96
+ it "fails if given an unknown type" do
97
+ assert_raises_with_message ArgumentError, "Invalid compression type nil" do
98
98
  cartage.compression = nil
99
99
  end
100
- assert_raises_with_message ArgumentError, 'Invalid compression type 3' do
100
+ assert_raises_with_message ArgumentError, "Invalid compression type 3" do
101
101
  cartage.compression = 3
102
102
  end
103
103
  assert_raises_with_message ArgumentError, 'Invalid compression type "foo"' do
104
- cartage.compression = 'foo'
104
+ cartage.compression = "foo"
105
105
  end
106
106
  end
107
107
 
108
- it 'affects #tar_compression_extension' do
109
- assert_equal '.bz2', cartage.tar_compression_extension
108
+ it "affects #tar_compression_extension" do
109
+ assert_equal ".bz2", cartage.tar_compression_extension
110
110
 
111
- cartage.compression = 'none'
112
- assert_equal '', cartage.tar_compression_extension
111
+ cartage.compression = "none"
112
+ assert_equal "", cartage.tar_compression_extension
113
113
 
114
- cartage.compression = 'gzip'
115
- assert_equal '.gz', cartage.tar_compression_extension
114
+ cartage.compression = "gzip"
115
+ assert_equal ".gz", cartage.tar_compression_extension
116
116
  end
117
117
 
118
- it 'affects #tar_compression_flag' do
119
- assert_equal 'j', cartage.tar_compression_flag
118
+ it "affects #tar_compression_flag" do
119
+ assert_equal "j", cartage.tar_compression_flag
120
120
 
121
- cartage.compression = 'none'
122
- assert_equal '', cartage.tar_compression_flag
121
+ cartage.compression = "none"
122
+ assert_equal "", cartage.tar_compression_flag
123
123
 
124
- cartage.compression = 'gzip'
125
- assert_equal 'z', cartage.tar_compression_flag
124
+ cartage.compression = "gzip"
125
+ assert_equal "z", cartage.tar_compression_flag
126
126
  end
127
127
  end
128
128
 
129
- describe '#dependency_cache, #dependency_cache_path, #dependency_cache_path=' do
130
- it 'defaults to #tmp_path{,/dependency-cache.tar.bz2}' do
129
+ describe "#dependency_cache, #dependency_cache_path, #dependency_cache_path=" do
130
+ it "defaults to #tmp_path{,/dependency-cache.tar.bz2}" do
131
131
  assert_equal cartage.tmp_path, cartage.dependency_cache_path
132
- assert_equal cartage.tmp_path.join('dependency-cache.tar.bz2'),
132
+ assert_equal cartage.tmp_path.join("dependency-cache.tar.bz2"),
133
133
  cartage.dependency_cache
134
134
  end
135
135
 
136
- it 'is affected by the compression setting' do
137
- cartage.compression = 'none'
138
- assert_equal cartage.tmp_path.join('dependency-cache.tar'),
136
+ it "is affected by the compression setting" do
137
+ cartage.compression = "none"
138
+ assert_equal cartage.tmp_path.join("dependency-cache.tar"),
139
139
  cartage.dependency_cache
140
140
 
141
- cartage.compression = 'gzip'
142
- assert_equal cartage.tmp_path.join('dependency-cache.tar.gz'),
141
+ cartage.compression = "gzip"
142
+ assert_equal cartage.tmp_path.join("dependency-cache.tar.gz"),
143
143
  cartage.dependency_cache
144
144
  end
145
145
 
146
- it 'becomes a Pathname' do
147
- cartage.dependency_cache_path = 'foo'
148
- assert_equal Pathname('foo').expand_path, cartage.dependency_cache_path
149
- assert_equal Pathname('foo/dependency-cache.tar.bz2').expand_path,
146
+ it "becomes a Pathname" do
147
+ cartage.dependency_cache_path = "foo"
148
+ assert_equal Pathname("foo").expand_path, cartage.dependency_cache_path
149
+ assert_equal Pathname("foo/dependency-cache.tar.bz2").expand_path,
150
150
  cartage.dependency_cache
151
151
  end
152
152
  end
153
153
 
154
- describe '#config' do
154
+ describe "#config" do
155
155
  let(:data) {
156
156
  {
157
- release_hashref: '12345',
157
+ release_hashref: "12345",
158
158
  x: 1,
159
159
  plugins: {
160
160
  test: {
@@ -178,11 +178,11 @@ describe Cartage do
178
178
  assert_equal config.commands.test, cartage.config(for_command: :test)
179
179
  end
180
180
 
181
- it 'knows the whole config' do
181
+ it "knows the whole config" do
182
182
  assert_equal config, cartage.config
183
183
  end
184
184
 
185
- it 'fails with an error when asking for plugin and command together' do
185
+ it "fails with an error when asking for plugin and command together" do
186
186
  exception = assert_raises ArgumentError do
187
187
  cartage.config(for_plugin: :test, for_command: :test)
188
188
  end
@@ -190,72 +190,72 @@ describe Cartage do
190
190
  end
191
191
  end
192
192
 
193
- describe '#dependency_cache' do
193
+ describe "#dependency_cache" do
194
194
  def assert_dependency_cache_equal(path)
195
195
  yield if block_given?
196
- assert_equal Pathname('.').join(path).expand_path, cartage.dependency_cache
196
+ assert_equal Pathname(".").join(path).expand_path, cartage.dependency_cache
197
197
  end
198
198
 
199
199
  it 'defaults to "tmp/dependency-cache.tar.bz2"' do
200
- assert_dependency_cache_equal 'tmp/dependency-cache.tar.bz2'
200
+ assert_dependency_cache_equal "tmp/dependency-cache.tar.bz2"
201
201
  end
202
202
 
203
- it 'can be overridden through #dependency_cache_path=' do
204
- assert_dependency_cache_equal 'tmp/dependency-cache.tar.bz2'
205
- assert_dependency_cache_equal 'tmpx/dependency-cache.tar.bz2' do
206
- cartage.dependency_cache_path = 'tmpx'
203
+ it "can be overridden through #dependency_cache_path=" do
204
+ assert_dependency_cache_equal "tmp/dependency-cache.tar.bz2"
205
+ assert_dependency_cache_equal "tmpx/dependency-cache.tar.bz2" do
206
+ cartage.dependency_cache_path = "tmpx"
207
207
  end
208
208
  end
209
209
  end
210
210
 
211
- describe '#release_hashref' do
212
- it 'returns the current hashref' do
211
+ describe "#release_hashref" do
212
+ it "returns the current hashref" do
213
213
  stub_cartage_repo_url do
214
- stub_backticks '12345' do
215
- assert_equal '12345', cartage.release_hashref
214
+ stub_backticks "12345" do
215
+ assert_equal "12345", cartage.release_hashref
216
216
  end
217
217
  end
218
218
  end
219
219
  end
220
220
 
221
- describe '#repo_url' do
222
- it 'returns the origin Fetch URL' do
223
- origin = <<-origin
224
- * remote origin
225
- Fetch URL: git@github.com:KineticCafe/cartage.git
226
- Push URL: git@github.com:KineticCafe/cartage.git
227
- HEAD branch: (not queried)
228
- Remote branch: (status not queried)
229
- master
230
- Local branch configured for 'git pull':
231
- master rebases onto remote master
232
- Local ref configured for 'git push' (status not queried):
233
- (matching) pushes to (matching)
234
- origin
221
+ describe "#repo_url" do
222
+ it "returns the origin Fetch URL" do
223
+ origin = <<~ORIGIN
224
+ * remote origin
225
+ Fetch URL: git@github.com:KineticCafe/cartage.git
226
+ Push URL: git@github.com:KineticCafe/cartage.git
227
+ HEAD branch: (not queried)
228
+ Remote branch: (status not queried)
229
+ master
230
+ Local branch configured for 'git pull':
231
+ master rebases onto remote master
232
+ Local ref configured for 'git push' (status not queried):
233
+ (matching) pushes to (matching)
234
+ ORIGIN
235
235
  stub_backticks origin do
236
- assert_equal 'git@github.com:KineticCafe/cartage.git',
236
+ assert_equal "git@github.com:KineticCafe/cartage.git",
237
237
  cartage.repo_url
238
238
  end
239
239
  end
240
240
  end
241
241
 
242
- describe 'computed paths' do
242
+ describe "computed paths" do
243
243
  before do
244
- cartage.root_path = '/a/b/c'
245
- cartage.name = 'test'
246
- cartage.timestamp = 'value'
244
+ cartage.root_path = "/a/b/c"
245
+ cartage.name = "test"
246
+ cartage.timestamp = "value"
247
247
  end
248
248
 
249
- it '#tmp_path is #root_path/tmp' do
250
- assert_equal Pathname('/a/b/c/tmp'), cartage.tmp_path
249
+ it "#tmp_path is #root_path/tmp" do
250
+ assert_equal Pathname("/a/b/c/tmp"), cartage.tmp_path
251
251
  end
252
252
 
253
- it '#work_path is #tmp_path/#name' do
254
- assert_equal Pathname('/a/b/c/tmp/test'), cartage.work_path
253
+ it "#work_path is #tmp_path/#name" do
254
+ assert_equal Pathname("/a/b/c/tmp/test"), cartage.work_path
255
255
  end
256
256
 
257
- it '#final_name is #tmp_path/#name-#timestamp' do
258
- assert_equal Pathname('/a/b/c/tmp/test-value'), cartage.final_name
257
+ it "#final_name is #tmp_path/#name-#timestamp" do
258
+ assert_equal Pathname("/a/b/c/tmp/test-value"), cartage.final_name
259
259
  end
260
260
 
261
261
  # it '#build_tarball.final_tarball is #final_name.tar#compression_extension' do
@@ -271,55 +271,55 @@ describe Cartage do
271
271
  # cartage.build_tarball.final_tarball
272
272
  # end
273
273
 
274
- it '#final_release_metadata_json is #final_name-release-metadata.json' do
275
- assert_equal Pathname('/a/b/c/tmp/test-value-release-metadata.json'),
274
+ it "#final_release_metadata_json is #final_name-release-metadata.json" do
275
+ assert_equal Pathname("/a/b/c/tmp/test-value-release-metadata.json"),
276
276
  cartage.final_release_metadata_json
277
277
  end
278
278
  end
279
279
 
280
- describe '#display' do
281
- it 'does not display a message if not verbose' do
280
+ describe "#display" do
281
+ it "does not display a message if not verbose" do
282
282
  cartage.verbose = false
283
283
  assert_silent do
284
- cartage.display 'hello'
284
+ cartage.display "hello"
285
285
  end
286
286
  end
287
287
 
288
- it 'displays a message if verbose' do
288
+ it "displays a message if verbose" do
289
289
  cartage.verbose = true
290
290
  assert_output "hello\n" do
291
- cartage.display 'hello'
291
+ cartage.display "hello"
292
292
  end
293
293
  end
294
294
 
295
- it 'does not display a message if verbose and quiet' do
295
+ it "does not display a message if verbose and quiet" do
296
296
  cartage.verbose = true
297
297
  cartage.quiet = true
298
298
  assert_silent do
299
- cartage.display 'hello'
299
+ cartage.display "hello"
300
300
  end
301
301
  end
302
302
  end
303
303
 
304
- describe '#run' do
304
+ describe "#run" do
305
305
  before do
306
- @command = %w(echo yes)
306
+ @command = %w[echo yes]
307
307
  end
308
308
 
309
- it 'displays the output if not verbose and not quiet' do
309
+ it "displays the output if not verbose and not quiet" do
310
310
  assert_output "yes\n" do
311
311
  cartage.send(:run, @command)
312
312
  end
313
313
  end
314
314
 
315
- it 'displays the command and output if verbose and not quiet' do
315
+ it "displays the command and output if verbose and not quiet" do
316
316
  cartage.verbose = true
317
317
  assert_output "echo yes\nyes\n" do
318
318
  cartage.send(:run, @command)
319
319
  end
320
320
  end
321
321
 
322
- it 'displays nothing if quiet' do
322
+ it "displays nothing if quiet" do
323
323
  cartage.verbose = true
324
324
  cartage.quiet = true
325
325
  assert_silent do
@@ -327,29 +327,29 @@ describe Cartage do
327
327
  end
328
328
  end
329
329
 
330
- it 'raises an exception on error' do
330
+ it "raises an exception on error" do
331
331
  cartage.quiet = true
332
332
  ex = assert_raises StandardError do
333
- cartage.send(:run, %w(false))
333
+ cartage.send(:run, %w[false])
334
334
  end
335
335
  assert_equal "Error running 'false'", ex.message
336
336
  end
337
337
  end
338
338
 
339
- describe '#release_metadata' do
340
- it 'has the structure we want' do
339
+ describe "#release_metadata" do
340
+ it "has the structure we want" do
341
341
  stub_cartage_repo_url do
342
- cartage.send(:release_hashref=, '12345')
342
+ cartage.send(:release_hashref=, "12345")
343
343
  cartage.timestamp = 3
344
344
 
345
345
  expected = {
346
346
  package: {
347
- name: 'repo-url',
347
+ name: "repo-url",
348
348
  repo: {
349
- type: 'git',
350
- url: 'git://host/repo-url.git'
349
+ type: "git",
350
+ url: "git://host/repo-url.git"
351
351
  },
352
- hashref: '12345',
352
+ hashref: "12345",
353
353
  timestamp: 3
354
354
  }
355
355
  }
@@ -359,7 +359,7 @@ describe Cartage do
359
359
  end
360
360
  end
361
361
 
362
- describe '#build_package' do
362
+ describe "#build_package" do
363
363
  def disable_unsafe_method(*names, &block)
364
364
  block ||= -> {}
365
365
  names.each { |name| cartage.define_singleton_method name, &block }
@@ -371,7 +371,7 @@ describe Cartage do
371
371
  disable_unsafe_method :create_dependency_cache, &->(_) {}
372
372
  end
373
373
 
374
- it 'requests :vendor_dependencies and :vendor_dependencies#path' do
374
+ it "requests :vendor_dependencies and :vendor_dependencies#path" do
375
375
  disable_unsafe_method :request_build_package
376
376
 
377
377
  verify_request = ->(f) { assert_equal :vendor_dependencies, f }
@@ -388,10 +388,10 @@ describe Cartage do
388
388
  end
389
389
  end
390
390
 
391
- it 'requests :pre_build_package, :build_package, and :post_build_package' do
391
+ it "requests :pre_build_package, :build_package, and :post_build_package" do
392
392
  disable_unsafe_method :vendor_dependencies
393
393
 
394
- requests = %i(pre_build_package build_package post_build_package)
394
+ requests = %i[pre_build_package build_package post_build_package]
395
395
 
396
396
  verify_request = ->(f) { assert_equal requests.shift, f }
397
397
 
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'minitest_config'
3
+ require "minitest_config"
4
4
 
5
- describe 'Cartage::BuildTarball' do
5
+ describe "Cartage::BuildTarball" do
6
6
  let(:config) {
7
7
  Cartage::Config.new(
8
- root_path: '/a/b/c',
9
- name: 'test',
10
- timestamp: 'value'
8
+ root_path: "/a/b/c",
9
+ name: "test",
10
+ timestamp: "value"
11
11
  )
12
12
  }
13
13
  let(:cartage) {
@@ -15,18 +15,18 @@ describe 'Cartage::BuildTarball' do
15
15
  }
16
16
  let(:subject) { cartage.build_tarball }
17
17
 
18
- it '#build_package requests :pre_build_tarball and :post_build_tarball' do
19
- requests = %i(pre_build_tarball post_build_tarball)
18
+ it "#build_package requests :pre_build_tarball and :post_build_tarball" do
19
+ requests = %i[pre_build_tarball post_build_tarball]
20
20
 
21
21
  verify_request = ->(f) { assert_equal requests.shift, f }
22
22
  verify_run = ->(c) {
23
23
  assert_equal [
24
- 'tar',
25
- 'cfj',
26
- '/a/b/c/tmp/test-value.tar.bz2',
27
- '-C',
28
- '/a/b/c/tmp',
29
- 'test'
24
+ "tar",
25
+ "cfj",
26
+ "/a/b/c/tmp/test-value.tar.bz2",
27
+ "-C",
28
+ "/a/b/c/tmp",
29
+ "test"
30
30
  ], c
31
31
  }
32
32
 
@@ -39,19 +39,19 @@ describe 'Cartage::BuildTarball' do
39
39
  assert_empty requests
40
40
  end
41
41
 
42
- describe '#package_name is dependent on Cartage configuration' do
43
- it 'is .tar.bz2 when compression is :bzip2' do
44
- assert_equal Pathname('/a/b/c/tmp/test-value.tar.bz2'), subject.package_name
42
+ describe "#package_name is dependent on Cartage configuration" do
43
+ it "is .tar.bz2 when compression is :bzip2" do
44
+ assert_equal Pathname("/a/b/c/tmp/test-value.tar.bz2"), subject.package_name
45
45
  end
46
46
 
47
- it 'is .tar when compression is :none' do
48
- cartage.compression = 'none'
49
- assert_equal Pathname('/a/b/c/tmp/test-value.tar'), subject.package_name
47
+ it "is .tar when compression is :none" do
48
+ cartage.compression = "none"
49
+ assert_equal Pathname("/a/b/c/tmp/test-value.tar"), subject.package_name
50
50
  end
51
51
 
52
- it 'is .tar.gz when compression is :gzip' do
53
- cartage.compression = 'gzip'
54
- assert_equal Pathname('/a/b/c/tmp/test-value.tar.gz'), subject.package_name
52
+ it "is .tar.gz when compression is :gzip" do
53
+ cartage.compression = "gzip"
54
+ assert_equal Pathname("/a/b/c/tmp/test-value.tar.gz"), subject.package_name
55
55
  end
56
56
  end
57
57
  end