modulesync 1.1.0 → 2.0.2

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.
data/Rakefile CHANGED
@@ -20,3 +20,27 @@ end
20
20
 
21
21
  task :test => %i[clean spec cucumber rubocop]
22
22
  task :default => %i[test]
23
+
24
+ begin
25
+ require 'github_changelog_generator/task'
26
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
27
+ config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
28
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix modulesync skip-changelog]
29
+ config.user = 'voxpupuli'
30
+ config.project = 'modulesync'
31
+ config.future_release = Gem::Specification.load("#{config.project}.gemspec").version
32
+ end
33
+
34
+ # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
35
+ require 'rbconfig'
36
+ if RbConfig::CONFIG['host_os'] =~ /linux/
37
+ task :changelog do
38
+ puts 'Fixing line endings...'
39
+ changelog_file = File.join(__dir__, 'CHANGELOG.md')
40
+ changelog_txt = File.read(changelog_file)
41
+ new_contents = changelog_txt.gsub(/\r\n/, "\n")
42
+ File.open(changelog_file, 'w') { |file| file.puts new_contents }
43
+ end
44
+ end
45
+ rescue LoadError
46
+ end
data/features/cli.feature CHANGED
@@ -4,21 +4,26 @@ Feature: CLI
4
4
  Scenario: When passing no arguments to the msync command
5
5
  When I run `msync`
6
6
  And the output should match /Commands:/
7
+ Then the exit status should be 1
7
8
 
8
9
  Scenario: When passing invalid arguments to the msync update command
9
10
  When I run `msync update`
10
11
  And the output should match /No value provided for required option/
12
+ Then the exit status should be 1
11
13
 
12
14
  Scenario: When passing invalid arguments to the msync hook command
13
15
  When I run `msync hook`
14
16
  And the output should match /Commands:/
17
+ Then the exit status should be 1
15
18
 
16
- Scenario: When running the help subcommand
19
+ Scenario: When running the help command
17
20
  When I run `msync help`
18
21
  And the output should match /Commands:/
22
+ Then the exit status should be 0
19
23
 
20
24
  Scenario: When overriding a setting from the config file on the command line
21
- Given a file named "managed_modules.yml" with:
25
+ Given a puppet module "puppet-test" from "fakenamespace"
26
+ And a file named "managed_modules.yml" with:
22
27
  """
23
28
  ---
24
29
  - puppet-test
@@ -26,10 +31,10 @@ Feature: CLI
26
31
  And a file named "modulesync.yml" with:
27
32
  """
28
33
  ---
29
- namespace: maestrodev
30
- git_base: 'git@github.com:'
34
+ namespace: default
31
35
  """
36
+ And a git_base option appended to "modulesync.yml" for local tests
32
37
  And a directory named "moduleroot"
33
- When I run `msync update --noop --git-base https://github.com/`
38
+ When I run `msync update --noop --namespace fakenamespace`
34
39
  Then the exit status should be 0
35
- And the output should not match /git@github.com:/
40
+ And the output should match /Syncing fakenamespace/
@@ -5,8 +5,7 @@ Feature: hook
5
5
  Given a directory named ".git/hooks"
6
6
  When I run `msync hook activate`
7
7
  Then the exit status should be 0
8
- Given I run `cat .git/hooks/pre-push`
9
- Then the output should contain "bash"
8
+ And the file named ".git/hooks/pre-push" should contain "bash"
10
9
 
11
10
  Scenario: Deactivating a hook
12
11
  Given a file named ".git/hooks/pre-push" with:
@@ -21,8 +20,7 @@ Feature: hook
21
20
  Given a directory named ".git/hooks"
22
21
  When I run `msync hook activate -a '--foo bar --baz quux' -b master`
23
22
  Then the exit status should be 0
24
- Given I run `cat .git/hooks/pre-push`
25
- Then the output should match:
23
+ And the file named ".git/hooks/pre-push" should contain:
26
24
  """
27
- "\$message" -n puppetlabs -b master --foo bar --baz quux
25
+ "$message" -n puppetlabs -b master --foo bar --baz quux
28
26
  """
@@ -1,47 +1,75 @@
1
- Given 'a mocked git configuration' do
2
- steps %(
3
- Given a mocked home directory
4
- And I run `git config --global user.name Test`
5
- And I run `git config --global user.email test@example.com`
6
- )
7
- end
1
+ require_relative '../../spec/helpers/faker/puppet_module_remote_repo'
8
2
 
9
- Given 'a remote module repository' do
3
+ Given 'a basic setup with a puppet module {string} from {string}' do |name, namespace|
10
4
  steps %(
11
- Given a directory named "sources"
12
- And I run `git clone https://github.com/maestrodev/puppet-test sources/puppet-test`
5
+ Given a mocked git configuration
6
+ And a puppet module "#{name}" from "#{namespace}"
13
7
  And a file named "managed_modules.yml" with:
14
8
  """
15
9
  ---
16
- - puppet-test
10
+ - #{name}
17
11
  """
12
+ And a file named "modulesync.yml" with:
13
+ """
14
+ ---
15
+ namespace: #{namespace}
16
+ """
17
+ And a git_base option appended to "modulesync.yml" for local tests
18
18
  )
19
- write_file('modulesync.yml', <<-CONFIG)
20
- ---
21
- namespace: sources
22
- git_base: file://#{expand_path('.')}/
23
- CONFIG
24
19
  end
25
20
 
26
- Given Regexp.new(/a remote module repository with "(.+?)" as the default branch/) do |branch|
21
+ Given 'a mocked git configuration' do
27
22
  steps %(
28
- Given a directory named "sources"
29
- And I run `git clone --mirror https://github.com/maestrodev/puppet-test sources/puppet-test`
30
- And a file named "managed_modules.yml" with:
31
- """
32
- ---
33
- - puppet-test
34
- """
23
+ Given a mocked home directory
24
+ And I run `git config --global user.name Aruba`
25
+ And I run `git config --global user.email aruba@example.com`
35
26
  )
36
- write_file('modulesync.yml', <<-CONFIG)
37
- ---
38
- namespace: sources
39
- git_base: file://#{expand_path('.')}/
40
- CONFIG
41
- cd('sources/puppet-test') do
42
- steps %(
43
- And I run `git branch -M master #{branch}`
44
- And I run `git symbolic-ref HEAD refs/heads/#{branch}`
45
- )
46
- end
27
+ end
28
+
29
+ Given 'a puppet module {string} from {string}' do |name, namespace|
30
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
31
+ pmrr.populate
32
+ end
33
+
34
+ Given 'a git_base option appended to "modulesync.yml" for local tests' do
35
+ File.write "#{Aruba.config.working_directory}/modulesync.yml", "\ngit_base: #{ModuleSync::Faker::PuppetModuleRemoteRepo.git_base}", mode: 'a'
36
+ end
37
+
38
+ Given 'the puppet module {string} from {string} is read-only' do |name, namespace|
39
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
40
+ pmrr.read_only = true
41
+ end
42
+
43
+ Then 'the puppet module {string} from {string} should have no commits between {string} and {string}' do |name, namespace, commit1, commit2|
44
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
45
+ expect(pmrr.commit_count_between(commit1, commit2)).to eq 0
46
+ end
47
+
48
+ Then 'the puppet module {string} from {string} should have( only) {int} commit(s) made by {string}' do |name, namespace, commit_count, author|
49
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
50
+ expect(pmrr.commit_count_by(author)).to eq commit_count
51
+ end
52
+
53
+ Then 'the puppet module {string} from {string} should have( only) {int} commit(s) made by {string} in branch {string}' do |name, namespace, commit_count, author, branch|
54
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
55
+ expect(pmrr.commit_count_by(author, branch)).to eq commit_count
56
+ end
57
+
58
+ Then 'the puppet module {string} from {string} should have no commits made by {string}' do |name, namespace, author|
59
+ step "the puppet module \"#{name}\" from \"#{namespace}\" should have 0 commits made by \"#{author}\""
60
+ end
61
+
62
+ Given 'the puppet module {string} from {string} has a file named {string} with:' do |name, namespace, filename, content|
63
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
64
+ pmrr.add_file(filename, content)
65
+ end
66
+
67
+ Then 'the puppet module {string} from {string} should have a branch {string} with a file named {string} which contains:' do |name, namespace, branch, filename, content|
68
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
69
+ expect(pmrr.read_file(filename, branch)).to include(content)
70
+ end
71
+
72
+ Given 'the puppet module {string} from {string} has the default branch named {string}' do |name, namespace, default_branch|
73
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
74
+ pmrr.default_branch = default_branch
47
75
  end
@@ -1,5 +1,9 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
+ require_relative '../../spec/helpers/faker'
4
+
5
+ ModuleSync::Faker.working_directory = File.expand_path('faker', Aruba.config.working_directory)
6
+
3
7
  Before do
4
8
  @aruba_timeout_seconds = 5
5
9
  end
@@ -2,17 +2,7 @@ Feature: update
2
2
  ModuleSync needs to update module boilerplate
3
3
 
4
4
  Scenario: Adding a new file
5
- Given a file named "managed_modules.yml" with:
6
- """
7
- ---
8
- - puppet-test
9
- """
10
- And a file named "modulesync.yml" with:
11
- """
12
- ---
13
- namespace: maestrodev
14
- git_base: https://github.com/
15
- """
5
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
16
6
  And a file named "config_defaults.yml" with:
17
7
  """
18
8
  ---
@@ -31,21 +21,11 @@ Feature: update
31
21
  Files added:
32
22
  test
33
23
  """
34
- Given I run `cat modules/maestrodev/puppet-test/test`
35
- Then the output should contain "aruba"
24
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
36
25
 
37
26
  Scenario: Using skip_broken option and adding a new file to repo without write access
38
- Given a file named "managed_modules.yml" with:
39
- """
40
- ---
41
- - puppet-test
42
- """
43
- And a file named "modulesync.yml" with:
44
- """
45
- ---
46
- namespace: maestrodev
47
- git_base: 'git@github.com:'
48
- """
27
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
28
+ And the puppet module "puppet-test" from "fakenamespace" is read-only
49
29
  And a file named "config_defaults.yml" with:
50
30
  """
51
31
  ---
@@ -59,19 +39,11 @@ Feature: update
59
39
  """
60
40
  When I run `msync update -s -m "Add test"`
61
41
  Then the exit status should be 0
42
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
62
43
 
63
44
  Scenario: Adding a new file to repo without write access
64
- Given a file named "managed_modules.yml" with:
65
- """
66
- ---
67
- - puppet-test
68
- """
69
- And a file named "modulesync.yml" with:
70
- """
71
- ---
72
- namespace: maestrodev
73
- git_base: 'git@github.com:'
74
- """
45
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
46
+ And the puppet module "puppet-test" from "fakenamespace" is read-only
75
47
  And a file named "config_defaults.yml" with:
76
48
  """
77
49
  ---
@@ -85,19 +57,10 @@ Feature: update
85
57
  """
86
58
  When I run `msync update -m "Add test" -r`
87
59
  Then the exit status should be 1
60
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
88
61
 
89
62
  Scenario: Adding a new file, without the .erb suffix
90
- Given a file named "managed_modules.yml" with:
91
- """
92
- ---
93
- - puppet-test
94
- """
95
- And a file named "modulesync.yml" with:
96
- """
97
- ---
98
- namespace: maestrodev
99
- git_base: https://github.com/
100
- """
63
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
101
64
  And a file named "config_defaults.yml" with:
102
65
  """
103
66
  ---
@@ -120,21 +83,11 @@ Feature: update
120
83
  Files added:
121
84
  test
122
85
  """
123
- Given I run `cat modules/maestrodev/puppet-test/test`
124
- Then the output should contain "aruba"
86
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
87
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
125
88
 
126
89
  Scenario: Adding a new file using global values
127
- Given a file named "managed_modules.yml" with:
128
- """
129
- ---
130
- - puppet-test
131
- """
132
- And a file named "modulesync.yml" with:
133
- """
134
- ---
135
- namespace: maestrodev
136
- git_base: https://github.com/
137
- """
90
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
138
91
  And a file named "config_defaults.yml" with:
139
92
  """
140
93
  ---
@@ -153,21 +106,11 @@ Feature: update
153
106
  Files added:
154
107
  test
155
108
  """
156
- Given I run `cat modules/maestrodev/puppet-test/test`
157
- Then the output should contain "aruba"
109
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
110
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
158
111
 
159
112
  Scenario: Adding a new file overriding global values
160
- Given a file named "managed_modules.yml" with:
161
- """
162
- ---
163
- - puppet-test
164
- """
165
- And a file named "modulesync.yml" with:
166
- """
167
- ---
168
- namespace: maestrodev
169
- git_base: https://github.com/
170
- """
113
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
171
114
  And a file named "config_defaults.yml" with:
172
115
  """
173
116
  ---
@@ -189,21 +132,11 @@ Feature: update
189
132
  Files added:
190
133
  test
191
134
  """
192
- Given I run `cat modules/maestrodev/puppet-test/test`
193
- Then the output should contain "aruba"
135
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
136
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
194
137
 
195
138
  Scenario: Adding a new file ignoring global values
196
- Given a file named "managed_modules.yml" with:
197
- """
198
- ---
199
- - puppet-test
200
- """
201
- And a file named "modulesync.yml" with:
202
- """
203
- ---
204
- namespace: maestrodev
205
- git_base: https://github.com/
206
- """
139
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
207
140
  And a file named "config_defaults.yml" with:
208
141
  """
209
142
  ---
@@ -225,21 +158,11 @@ Feature: update
225
158
  Files added:
226
159
  test
227
160
  """
228
- Given I run `cat modules/maestrodev/puppet-test/test`
229
- Then the output should contain "aruba"
161
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
162
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
230
163
 
231
164
  Scenario: Adding a file that ERB can't parse
232
- Given a file named "managed_modules.yml" with:
233
- """
234
- ---
235
- - puppet-test
236
- """
237
- And a file named "modulesync.yml" with:
238
- """
239
- ---
240
- namespace: maestrodev
241
- git_base: https://github.com/
242
- """
165
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
243
166
  And a file named "config_defaults.yml" with:
244
167
  """
245
168
  ---
@@ -255,19 +178,10 @@ Feature: update
255
178
  """
256
179
  When I run `msync update --noop`
257
180
  Then the exit status should be 1
181
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
258
182
 
259
183
  Scenario: Using skip_broken option with invalid files
260
- Given a file named "managed_modules.yml" with:
261
- """
262
- ---
263
- - puppet-test
264
- """
265
- And a file named "modulesync.yml" with:
266
- """
267
- ---
268
- namespace: maestrodev
269
- git_base: https://github.com/
270
- """
184
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
271
185
  And a file named "config_defaults.yml" with:
272
186
  """
273
187
  ---
@@ -283,19 +197,10 @@ Feature: update
283
197
  """
284
198
  When I run `msync update --noop -s`
285
199
  Then the exit status should be 0
200
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
286
201
 
287
202
  Scenario: Using skip_broken and fail_on_warnings options with invalid files
288
- Given a file named "managed_modules.yml" with:
289
- """
290
- ---
291
- - puppet-test
292
- """
293
- And a file named "modulesync.yml" with:
294
- """
295
- ---
296
- namespace: maestrodev
297
- git_base: https://github.com/
298
- """
203
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
299
204
  And a file named "config_defaults.yml" with:
300
205
  """
301
206
  ---
@@ -311,18 +216,13 @@ Feature: update
311
216
  """
312
217
  When I run `msync update --noop --skip_broken --fail_on_warnings`
313
218
  Then the exit status should be 1
219
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
314
220
 
315
221
  Scenario: Modifying an existing file
316
- Given a file named "managed_modules.yml" with:
317
- """
318
- ---
319
- - puppet-test
222
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
223
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
320
224
  """
321
- And a file named "modulesync.yml" with:
322
- """
323
- ---
324
- namespace: maestrodev
325
- git_base: https://github.com/
225
+ source 'https://example.com'
326
226
  """
327
227
  And a file named "config_defaults.yml" with:
328
228
  """
@@ -342,15 +242,18 @@ Feature: update
342
242
  Files changed:
343
243
  +diff --git a/Gemfile b/Gemfile
344
244
  """
345
- Given I run `cat modules/maestrodev/puppet-test/Gemfile`
346
- Then the output should contain:
245
+ And the file named "modules/fakenamespace/puppet-test/Gemfile" should contain:
347
246
  """
348
247
  source 'https://somehost.com'
349
248
  """
249
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
350
250
 
351
251
  Scenario: Modifying an existing file and committing the change
352
- Given a mocked git configuration
353
- And a remote module repository
252
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
253
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
254
+ """
255
+ source 'https://example.com'
256
+ """
354
257
  And a file named "config_defaults.yml" with:
355
258
  """
356
259
  ---
@@ -364,30 +267,25 @@ Feature: update
364
267
  """
365
268
  When I run `msync update -m "Update Gemfile" -r test`
366
269
  Then the exit status should be 0
367
- Given I cd to "sources/puppet-test"
368
- And I run `git checkout test`
369
- Then the file "Gemfile" should contain:
270
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
271
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
272
+ And the puppet module "puppet-test" from "fakenamespace" should have a branch "test" with a file named "Gemfile" which contains:
370
273
  """
371
274
  source 'https://somehost.com'
372
275
  """
373
276
 
374
277
  Scenario: Setting an existing file to unmanaged
375
- Given a file named "managed_modules.yml" with:
376
- """
377
- ---
378
- - puppet-test
379
- """
380
- And a file named "modulesync.yml" with:
278
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
279
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
381
280
  """
382
- ---
383
- namespace: maestrodev
384
- git_base: https://github.com/
281
+ source 'https://rubygems.org'
385
282
  """
386
283
  And a file named "config_defaults.yml" with:
387
284
  """
388
285
  ---
389
286
  Gemfile:
390
287
  unmanaged: true
288
+ gem_source: https://somehost.com
391
289
  """
392
290
  And a directory named "moduleroot"
393
291
  And a file named "moduleroot/Gemfile.erb" with:
@@ -405,24 +303,14 @@ Feature: update
405
303
  Not managing Gemfile in puppet-test
406
304
  """
407
305
  And the exit status should be 0
408
- Given I run `cat modules/maestrodev/puppet-test/Gemfile`
409
- Then the output should contain:
306
+ And the file named "modules/fakenamespace/puppet-test/Gemfile" should contain:
410
307
  """
411
308
  source 'https://rubygems.org'
412
309
  """
310
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
413
311
 
414
312
  Scenario: Setting an existing file to deleted
415
- Given a file named "managed_modules.yml" with:
416
- """
417
- ---
418
- - puppet-test
419
- """
420
- And a file named "modulesync.yml" with:
421
- """
422
- ---
423
- namespace: maestrodev
424
- git_base: https://github.com/
425
- """
313
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
426
314
  And a file named "config_defaults.yml" with:
427
315
  """
428
316
  ---
@@ -434,6 +322,10 @@ Feature: update
434
322
  """
435
323
  source '<%= @configs['gem_source'] %>'
436
324
  """
325
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
326
+ """
327
+ source 'https://rubygems.org'
328
+ """
437
329
  When I run `msync update --noop`
438
330
  Then the output should match:
439
331
  """
@@ -442,19 +334,10 @@ Feature: update
442
334
  deleted file mode 100644
443
335
  """
444
336
  And the exit status should be 0
337
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
445
338
 
446
339
  Scenario: Setting a non-existent file to deleted
447
- Given a file named "managed_modules.yml" with:
448
- """
449
- ---
450
- - puppet-test
451
- """
452
- And a file named "modulesync.yml" with:
453
- """
454
- ---
455
- namespace: maestrodev
456
- git_base: https://github.com/
457
- """
340
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
458
341
  And a file named "config_defaults.yml" with:
459
342
  """
460
343
  ---
@@ -464,19 +347,10 @@ Feature: update
464
347
  And a directory named "moduleroot"
465
348
  When I run `msync update -m 'deletes a file that doesnt exist!' -f puppet-test`
466
349
  And the exit status should be 0
350
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
467
351
 
468
352
  Scenario: Setting a directory to unmanaged
469
- Given a file named "managed_modules.yml" with:
470
- """
471
- ---
472
- - puppetlabs-apache
473
- """
474
- And a file named "modulesync.yml" with:
475
- """
476
- ---
477
- namespace: puppetlabs
478
- git_base: https://github.com/
479
- """
353
+ Given a basic setup with a puppet module "puppet-apache" from "puppetlabs"
480
354
  And a file named "config_defaults.yml" with:
481
355
  """
482
356
  ---
@@ -488,36 +362,26 @@ Feature: update
488
362
  """
489
363
  some spec_helper fud
490
364
  """
491
- And a directory named "modules/puppetlabs/puppetlabs-apache/spec"
492
- And a file named "modules/puppetlabs/puppetlabs-apache/spec/spec_helper.rb" with:
365
+ And a directory named "modules/puppetlabs/puppet-apache/spec"
366
+ And a file named "modules/puppetlabs/puppet-apache/spec/spec_helper.rb" with:
493
367
  """
494
368
  This is a fake spec_helper!
495
369
  """
496
370
  When I run `msync update --offline`
497
371
  Then the output should contain:
498
372
  """
499
- Not managing spec/spec_helper.rb in puppetlabs-apache
373
+ Not managing spec/spec_helper.rb in puppet-apache
500
374
  """
501
375
  And the exit status should be 0
502
- Given I run `cat modules/puppetlabs/puppetlabs-apache/spec/spec_helper.rb`
503
- Then the output should contain:
376
+ And the file named "modules/puppetlabs/puppet-apache/spec/spec_helper.rb" should contain:
504
377
  """
505
378
  This is a fake spec_helper!
506
379
  """
507
380
  And the exit status should be 0
381
+ And the puppet module "puppet-apache" from "puppetlabs" should have no commits made by "Aruba"
508
382
 
509
383
  Scenario: Adding a new file in a new subdirectory
510
- Given a file named "managed_modules.yml" with:
511
- """
512
- ---
513
- - puppet-test
514
- """
515
- And a file named "modulesync.yml" with:
516
- """
517
- ---
518
- namespace: maestrodev
519
- git_base: https://github.com/
520
- """
384
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
521
385
  And a file named "config_defaults.yml" with:
522
386
  """
523
387
  ---
@@ -538,24 +402,14 @@ Feature: update
538
402
  Files added:
539
403
  spec/spec_helper.rb
540
404
  """
541
- Given I run `cat modules/maestrodev/puppet-test/spec/spec_helper.rb`
542
- Then the output should contain:
405
+ And the file named "modules/fakenamespace/puppet-test/spec/spec_helper.rb" should contain:
543
406
  """
544
407
  require 'puppetlabs_spec_helper/module_helper'
545
408
  """
409
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
546
410
 
547
411
  Scenario: Updating offline
548
- Given a file named "managed_modules.yml" with:
549
- """
550
- ---
551
- - puppet-test
552
- """
553
- And a file named "modulesync.yml" with:
554
- """
555
- ---
556
- namespace: maestrodev
557
- git_base: https://github.com/
558
- """
412
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
559
413
  And a file named "config_defaults.yml" with:
560
414
  """
561
415
  ---
@@ -572,19 +426,15 @@ Feature: update
572
426
  When I run `msync update --offline`
573
427
  Then the exit status should be 0
574
428
  And the output should not match /Files (changed|added|deleted):/
429
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
575
430
 
576
431
  Scenario: Pulling a module that already exists in the modules directory
577
- Given a file named "managed_modules.yml" with:
578
- """
579
- ---
580
- - maestrodev/puppet-test
581
- """
582
- And a file named "modulesync.yml" with:
583
- """
584
- ---
585
- git_base: https://github.com/
586
- """
587
- And a file named "config_defaults.yml" with:
432
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
433
+ And a directory named "moduleroot"
434
+ When I run `msync update --message "First update run"`
435
+ Then the exit status should be 0
436
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
437
+ Given a file named "config_defaults.yml" with:
588
438
  """
589
439
  ---
590
440
  spec/spec_helper.rb:
@@ -597,20 +447,6 @@ Feature: update
597
447
  require '<%= required %>'
598
448
  <% end %>
599
449
  """
600
- Given I run `git init modules/maestrodev/puppet-test`
601
- Given a file named "modules/maestrodev/puppet-test/.git/config" with:
602
- """
603
- [core]
604
- repositoryformatversion = 0
605
- filemode = true
606
- bare = false
607
- logallrefupdates = true
608
- ignorecase = true
609
- precomposeunicode = true
610
- [remote "origin"]
611
- url = https://github.com/maestrodev/puppet-test.git
612
- fetch = +refs/heads/*:refs/remotes/origin/*
613
- """
614
450
  When I run `msync update --noop`
615
451
  Then the exit status should be 0
616
452
  And the output should match:
@@ -618,37 +454,23 @@ Feature: update
618
454
  Files added:
619
455
  spec/spec_helper.rb
620
456
  """
457
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
621
458
 
622
- Scenario: When running update with no changes
623
- Given a file named "managed_modules.yml" with:
624
- """
625
- ---
626
- - puppet-test
627
- """
628
- And a file named "modulesync.yml" with:
629
- """
630
- ---
631
- namespace: maestrodev
632
- git_base: https://github.com/
633
- """
459
+ Scenario: When running update without changes
460
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
634
461
  And a directory named "moduleroot"
635
- When I run `msync update --noop`
462
+ When I run `msync update --message "Running without changes"`
636
463
  Then the exit status should be 0
637
- And the output should not match /diff/
464
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
638
465
 
639
466
  Scenario: When specifying configurations in managed_modules.yml
640
- Given a file named "managed_modules.yml" with:
467
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
468
+ And a file named "managed_modules.yml" with:
641
469
  """
642
470
  ---
643
471
  puppet-test:
644
472
  module_name: test
645
473
  """
646
- And a file named "modulesync.yml" with:
647
- """
648
- ---
649
- namespace: maestrodev
650
- git_base: https://github.com/
651
- """
652
474
  And a file named "config_defaults.yml" with:
653
475
  """
654
476
  ---
@@ -667,11 +489,14 @@ Feature: update
667
489
  Files added:
668
490
  test
669
491
  """
670
- Given I run `cat modules/maestrodev/puppet-test/test`
671
- Then the output should contain "aruba"
492
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
493
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
672
494
 
673
495
  Scenario: When specifying configurations in managed_modules.yml and using a filter
674
- Given a file named "managed_modules.yml" with:
496
+ Given a mocked git configuration
497
+ And a puppet module "puppet-test" from "fakenamespace"
498
+ And a puppet module "puppet-blacksmith" from "fakenamespace"
499
+ And a file named "managed_modules.yml" with:
675
500
  """
676
501
  ---
677
502
  puppet-blacksmith:
@@ -681,9 +506,9 @@ Feature: update
681
506
  And a file named "modulesync.yml" with:
682
507
  """
683
508
  ---
684
- namespace: maestrodev
685
- git_base: https://github.com/
509
+ namespace: fakenamespace
686
510
  """
511
+ And a git_base option appended to "modulesync.yml" for local tests
687
512
  And a file named "config_defaults.yml" with:
688
513
  """
689
514
  ---
@@ -702,12 +527,15 @@ Feature: update
702
527
  Files added:
703
528
  test
704
529
  """
705
- Given I run `cat modules/maestrodev/puppet-test/test`
706
- Then the output should contain "aruba"
707
- And a directory named "modules/maestrodev/puppet-blacksmith" should not exist
530
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
531
+ And a directory named "modules/fakenamespace/puppet-blacksmith" should not exist
532
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
708
533
 
709
534
  Scenario: When specifying configurations in managed_modules.yml and using a negative filter
710
- Given a file named "managed_modules.yml" with:
535
+ Given a mocked git configuration
536
+ And a puppet module "puppet-test" from "fakenamespace"
537
+ And a puppet module "puppet-blacksmith" from "fakenamespace"
538
+ And a file named "managed_modules.yml" with:
711
539
  """
712
540
  ---
713
541
  puppet-blacksmith:
@@ -717,9 +545,9 @@ Feature: update
717
545
  And a file named "modulesync.yml" with:
718
546
  """
719
547
  ---
720
- namespace: maestrodev
721
- git_base: https://github.com/
548
+ namespace: fakenamespace
722
549
  """
550
+ And a git_base option appended to "modulesync.yml" for local tests
723
551
  And a file named "config_defaults.yml" with:
724
552
  """
725
553
  ---
@@ -738,21 +566,12 @@ Feature: update
738
566
  Files added:
739
567
  test
740
568
  """
741
- Given I run `cat modules/maestrodev/puppet-test/test`
742
- Then the output should contain "aruba"
743
- And a directory named "modules/maestrodev/puppet-blacksmith" should not exist
569
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
570
+ And a directory named "modules/fakenamespace/puppet-blacksmith" should not exist
571
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
744
572
 
745
573
  Scenario: Updating a module with a .sync.yml file
746
- Given a file named "managed_modules.yml" with:
747
- """
748
- ---
749
- - maestrodev/puppet-test
750
- """
751
- And a file named "modulesync.yml" with:
752
- """
753
- ---
754
- git_base: https://github.com/
755
- """
574
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
756
575
  And a file named "config_defaults.yml" with:
757
576
  """
758
577
  ---
@@ -775,21 +594,7 @@ Feature: update
775
594
  <%= @configs['global-to-overwrite'] %>
776
595
  <%= @configs['module-default'] %>
777
596
  """
778
- Given I run `git init modules/maestrodev/puppet-test`
779
- Given a file named "modules/maestrodev/puppet-test/.git/config" with:
780
- """
781
- [core]
782
- repositoryformatversion = 0
783
- filemode = true
784
- bare = false
785
- logallrefupdates = true
786
- ignorecase = true
787
- precomposeunicode = true
788
- [remote "origin"]
789
- url = https://github.com/maestrodev/puppet-test.git
790
- fetch = +refs/heads/*:refs/remotes/origin/*
791
- """
792
- Given a file named "modules/maestrodev/puppet-test/.sync.yml" with:
597
+ And the puppet module "puppet-test" from "fakenamespace" has a file named ".sync.yml" with:
793
598
  """
794
599
  ---
795
600
  :global:
@@ -804,16 +609,19 @@ Feature: update
804
609
  """
805
610
  Not managing spec/spec_helper.rb in puppet-test
806
611
  """
807
- Given I run `cat modules/maestrodev/puppet-test/global-test.md`
808
- Then the output should match:
612
+ And the file named "modules/fakenamespace/puppet-test/global-test.md" should contain:
809
613
  """
810
614
  some-default
811
615
  it-is-overwritten
812
616
  some-value
813
617
  """
618
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
814
619
 
815
620
  Scenario: Module with custom namespace
816
- Given a file named "managed_modules.yml" with:
621
+ Given a mocked git configuration
622
+ And a puppet module "puppet-test" from "fakenamespace"
623
+ And a puppet module "puppet-lib-file_concat" from "electrical"
624
+ And a file named "managed_modules.yml" with:
817
625
  """
818
626
  ---
819
627
  - puppet-test
@@ -822,9 +630,9 @@ Feature: update
822
630
  And a file named "modulesync.yml" with:
823
631
  """
824
632
  ---
825
- namespace: maestrodev
826
- git_base: https://github.com/
633
+ namespace: fakenamespace
827
634
  """
635
+ And a git_base option appended to "modulesync.yml" for local tests
828
636
  And a file named "config_defaults.yml" with:
829
637
  """
830
638
  ---
@@ -843,23 +651,13 @@ Feature: update
843
651
  Files added:
844
652
  test
845
653
  """
846
- Given I run `cat modules/maestrodev/puppet-test/.git/config`
847
- Then the output should contain "url = https://github.com/maestrodev/puppet-test.git"
848
- Given I run `cat modules/electrical/puppet-lib-file_concat/.git/config`
849
- Then the output should contain "url = https://github.com/electrical/puppet-lib-file_concat.git"
654
+ And the file named "modules/fakenamespace/puppet-test/.git/config" should match /^\s+url = .*fakenamespace.puppet-test$/
655
+ And the file named "modules/electrical/puppet-lib-file_concat/.git/config" should match /^\s+url = .*electrical.puppet-lib-file_concat$/
656
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
657
+ And the puppet module "puppet-lib-file_concat" from "electrical" should have no commits made by "Aruba"
850
658
 
851
659
  Scenario: Modifying an existing file with values exposed by the module
852
- Given a file named "managed_modules.yml" with:
853
- """
854
- ---
855
- - puppet-test
856
- """
857
- And a file named "modulesync.yml" with:
858
- """
859
- ---
860
- namespace: maestrodev
861
- git_base: https://github.com/
862
- """
660
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
863
661
  And a file named "config_defaults.yml" with:
864
662
  """
865
663
  ---
@@ -868,7 +666,12 @@ Feature: update
868
666
  And a directory named "moduleroot"
869
667
  And a file named "moduleroot/README.md.erb" with:
870
668
  """
871
- echo '<%= @configs[:git_base] + @configs[:namespace] %>'
669
+ module: <%= @configs[:puppet_module] %>
670
+ namespace: <%= @configs[:namespace] %>
671
+ """
672
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "README.md" with:
673
+ """
674
+ Hello world!
872
675
  """
873
676
  When I run `msync update --noop`
874
677
  Then the exit status should be 0
@@ -877,15 +680,15 @@ Feature: update
877
680
  Files changed:
878
681
  +diff --git a/README.md b/README.md
879
682
  """
880
- Given I run `cat modules/maestrodev/puppet-test/README.md`
881
- Then the output should contain:
683
+ And the file named "modules/fakenamespace/puppet-test/README.md" should contain:
882
684
  """
883
- echo 'https://github.com/maestrodev'
685
+ module: puppet-test
686
+ namespace: fakenamespace
884
687
  """
688
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
885
689
 
886
690
  Scenario: Running the same update twice and pushing to a remote branch
887
- Given a mocked git configuration
888
- And a remote module repository
691
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
889
692
  And a file named "config_defaults.yml" with:
890
693
  """
891
694
  ---
@@ -899,15 +702,41 @@ Feature: update
899
702
  """
900
703
  When I run `msync update -m "Update Gemfile" -r test`
901
704
  Then the exit status should be 0
705
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
706
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
902
707
  Given I remove the directory "modules"
903
708
  When I run `msync update -m "Update Gemfile" -r test`
904
709
  Then the exit status should be 0
905
710
  Then the output should not contain "error"
906
711
  Then the output should not contain "rejected"
712
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
713
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
714
+
715
+ Scenario: Creating a GitHub PR with an update
716
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
717
+ And a directory named "moduleroot"
718
+ And I set the environment variables to:
719
+ | variable | value |
720
+ | GITHUB_TOKEN | foobar |
721
+ When I run `msync update --noop --branch managed_update --pr`
722
+ Then the output should contain "Would submit PR "
723
+ And the exit status should be 0
724
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
725
+
726
+ Scenario: Creating a GitLab MR with an update
727
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
728
+ And a directory named "moduleroot"
729
+ And I set the environment variables to:
730
+ | variable | value |
731
+ | GITLAB_TOKEN | foobar |
732
+ When I run `msync update --noop --branch managed_update --pr`
733
+ Then the output should contain "Would submit MR "
734
+ And the exit status should be 0
735
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
907
736
 
908
737
  Scenario: Repository with a default branch other than master
909
- Given a mocked git configuration
910
- And a remote module repository with "develop" as the default branch
738
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
739
+ And the puppet module "puppet-test" from "fakenamespace" has the default branch named "develop"
911
740
  And a file named "config_defaults.yml" with:
912
741
  """
913
742
  ---
@@ -921,24 +750,16 @@ Feature: update
921
750
  """
922
751
  When I run `msync update -m "Update Gemfile"`
923
752
  Then the exit status should be 0
924
- Then the output should contain "Using repository's default branch: develop"
753
+ And the output should contain "Using repository's default branch: develop"
754
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
755
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "develop"
925
756
 
926
- Scenario: Adding a new file from a template using meta data
757
+ Scenario: Adding a new file from a template using metadata
758
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
927
759
  And a file named "config_defaults.yml" with:
928
760
  """
929
761
  ---
930
762
  """
931
- Given a file named "managed_modules.yml" with:
932
- """
933
- ---
934
- - puppet-test
935
- """
936
- And a file named "modulesync.yml" with:
937
- """
938
- ---
939
- namespace: maestrodev
940
- git_base: https://github.com/
941
- """
942
763
  And a directory named "moduleroot"
943
764
  And a file named "moduleroot/test.erb" with:
944
765
  """
@@ -948,10 +769,10 @@ Feature: update
948
769
  """
949
770
  When I run `msync update --noop`
950
771
  Then the exit status should be 0
951
- Given I run `cat modules/maestrodev/puppet-test/test`
952
- Then the output should contain:
772
+ And the file named "modules/fakenamespace/puppet-test/test" should contain:
953
773
  """
954
774
  module: puppet-test
955
- target: modules/maestrodev/puppet-test/test
956
- workdir: modules/maestrodev/puppet-test
775
+ target: modules/fakenamespace/puppet-test/test
776
+ workdir: modules/fakenamespace/puppet-test
957
777
  """
778
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"