r10k 3.9.0 → 3.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +1 -1
  3. data/.github/workflows/rspec_tests.yml +1 -1
  4. data/.github/workflows/stale.yml +19 -0
  5. data/CHANGELOG.mkd +24 -0
  6. data/doc/dynamic-environments/configuration.mkd +13 -6
  7. data/integration/Rakefile +1 -1
  8. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +3 -9
  9. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +8 -14
  10. data/lib/r10k/action/base.rb +10 -0
  11. data/lib/r10k/action/deploy/display.rb +42 -9
  12. data/lib/r10k/action/deploy/environment.rb +70 -41
  13. data/lib/r10k/action/deploy/module.rb +51 -29
  14. data/lib/r10k/action/puppetfile/check.rb +3 -1
  15. data/lib/r10k/action/puppetfile/install.rb +20 -23
  16. data/lib/r10k/action/puppetfile/purge.rb +8 -2
  17. data/lib/r10k/action/runner.rb +11 -6
  18. data/lib/r10k/content_synchronizer.rb +83 -0
  19. data/lib/r10k/deployment.rb +1 -1
  20. data/lib/r10k/environment/base.rb +21 -1
  21. data/lib/r10k/environment/git.rb +0 -3
  22. data/lib/r10k/environment/svn.rb +4 -6
  23. data/lib/r10k/environment/with_modules.rb +18 -10
  24. data/lib/r10k/git/cache.rb +1 -1
  25. data/lib/r10k/initializers.rb +7 -0
  26. data/lib/r10k/module.rb +1 -1
  27. data/lib/r10k/module/base.rb +17 -1
  28. data/lib/r10k/module/forge.rb +29 -19
  29. data/lib/r10k/module/git.rb +23 -14
  30. data/lib/r10k/module/local.rb +1 -0
  31. data/lib/r10k/module/svn.rb +12 -9
  32. data/lib/r10k/module_loader/puppetfile.rb +195 -0
  33. data/lib/r10k/module_loader/puppetfile/dsl.rb +37 -0
  34. data/lib/r10k/puppetfile.rb +111 -202
  35. data/lib/r10k/settings.rb +3 -0
  36. data/lib/r10k/source/base.rb +14 -0
  37. data/lib/r10k/source/git.rb +19 -6
  38. data/lib/r10k/source/hash.rb +1 -3
  39. data/lib/r10k/source/svn.rb +4 -2
  40. data/lib/r10k/util/cleaner.rb +21 -0
  41. data/lib/r10k/util/purgeable.rb +70 -8
  42. data/lib/r10k/version.rb +1 -1
  43. data/locales/r10k.pot +67 -71
  44. data/spec/fixtures/unit/action/r10k_forge_auth.yaml +4 -0
  45. data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +3 -0
  46. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_subdir_2/ignored_1 +0 -0
  47. data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
  48. data/spec/r10k-mocks/mock_source.rb +1 -1
  49. data/spec/shared-examples/puppetfile-action.rb +7 -7
  50. data/spec/unit/action/deploy/display_spec.rb +32 -6
  51. data/spec/unit/action/deploy/environment_spec.rb +85 -48
  52. data/spec/unit/action/deploy/module_spec.rb +163 -31
  53. data/spec/unit/action/puppetfile/check_spec.rb +2 -2
  54. data/spec/unit/action/puppetfile/install_spec.rb +31 -10
  55. data/spec/unit/action/puppetfile/purge_spec.rb +25 -5
  56. data/spec/unit/action/runner_spec.rb +49 -25
  57. data/spec/unit/git/cache_spec.rb +14 -0
  58. data/spec/unit/module/forge_spec.rb +23 -14
  59. data/spec/unit/module/git_spec.rb +8 -8
  60. data/spec/unit/module_loader/puppetfile_spec.rb +330 -0
  61. data/spec/unit/module_spec.rb +22 -5
  62. data/spec/unit/puppetfile_spec.rb +123 -203
  63. data/spec/unit/settings_spec.rb +6 -2
  64. data/spec/unit/util/purgeable_spec.rb +40 -14
  65. metadata +12 -2
@@ -30,12 +30,12 @@ describe R10K::Module do
30
30
  [ 'bar/quux',
31
31
  'bar-quux',
32
32
  ].each do |scenario|
33
- it "accepts a name matching #{scenario} and args nil" do
34
- obj = R10K::Module.new(scenario, '/modulepath', nil)
33
+ it "accepts a name matching #{scenario} and version nil" do
34
+ obj = R10K::Module.new(scenario, '/modulepath', { version: nil })
35
35
  expect(obj).to be_a_kind_of(R10K::Module::Forge)
36
36
  end
37
37
  end
38
- [ '8.0.0',
38
+ [ {version: '8.0.0'},
39
39
  {type: 'forge', version: '8.0.0'},
40
40
  ].each do |scenario|
41
41
  it "accepts a name matching bar-quux and args #{scenario.inspect}" do
@@ -65,7 +65,7 @@ describe R10K::Module do
65
65
  end
66
66
 
67
67
  it 'sets the expected version to what is found in the metadata' do
68
- obj = R10K::Module.new(@title, @dirname, nil)
68
+ obj = R10K::Module.new(@title, @dirname, {version: nil})
69
69
  expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('1.2.0')
70
70
  end
71
71
  end
@@ -73,7 +73,24 @@ describe R10K::Module do
73
73
 
74
74
  it "raises an error if delegation fails" do
75
75
  expect {
76
- R10K::Module.new('bar!quux', '/modulepath', ["NOPE NOPE NOPE NOPE!"])
76
+ R10K::Module.new('bar!quux', '/modulepath', {version: ["NOPE NOPE NOPE NOPE!"]})
77
77
  }.to raise_error RuntimeError, /doesn't have an implementation/
78
78
  end
79
+
80
+ describe 'when a user passes a `default_branch_override`' do
81
+ [ ['name', {git: 'git url'}],
82
+ ['name', {type: 'git', source: 'git url'}],
83
+ ['name', {svn: 'svn url'}],
84
+ ['name', {type: 'svn', source: 'svn url'}],
85
+ ['namespace-name', {version: '8.0.0'}],
86
+ ['namespace-name', {type: 'forge', version: '8.0.0'}]
87
+ ].each do |(name, options)|
88
+ it 'can handle the default_branch_override option' do
89
+ expect {
90
+ obj = R10K::Module.new(name, '/modulepath', options.merge({default_branch_override: 'foo'}))
91
+ expect(obj).to be_a_kind_of(R10K::Module::Base)
92
+ }.not_to raise_error
93
+ end
94
+ end
95
+ end
79
96
  end
@@ -6,9 +6,7 @@ describe R10K::Puppetfile do
6
6
  subject do
7
7
  described_class.new(
8
8
  '/some/nonexistent/basedir',
9
- nil,
10
- nil,
11
- 'Puppetfile.r10k'
9
+ {puppetfile_name: 'Puppetfile.r10k'}
12
10
  )
13
11
  end
14
12
 
@@ -23,9 +21,25 @@ end
23
21
  describe R10K::Puppetfile do
24
22
 
25
23
  subject do
26
- described_class.new(
27
- '/some/nonexistent/basedir'
28
- )
24
+ described_class.new( '/some/nonexistent/basedir', {})
25
+ end
26
+
27
+ describe "backwards compatibility with older calling conventions" do
28
+ it "honors all arguments correctly" do
29
+ puppetfile = described_class.new('/some/nonexistant/basedir', '/some/nonexistant/basedir/site-modules', nil, 'Pupupupetfile', true)
30
+ expect(puppetfile.force).to eq(true)
31
+ expect(puppetfile.moduledir).to eq('/some/nonexistant/basedir/site-modules')
32
+ expect(puppetfile.puppetfile_path).to eq('/some/nonexistant/basedir/Pupupupetfile')
33
+ expect(puppetfile.overrides).to eq({})
34
+ end
35
+
36
+ it "handles defaults correctly" do
37
+ puppetfile = described_class.new('/some/nonexistant/basedir', nil, nil, nil)
38
+ expect(puppetfile.force).to eq(false)
39
+ expect(puppetfile.moduledir).to eq('/some/nonexistant/basedir/modules')
40
+ expect(puppetfile.puppetfile_path).to eq('/some/nonexistant/basedir/Puppetfile')
41
+ expect(puppetfile.overrides).to eq({})
42
+ end
29
43
  end
30
44
 
31
45
  describe "the default moduledir" do
@@ -53,230 +67,136 @@ describe R10K::Puppetfile do
53
67
  end
54
68
  end
55
69
 
56
- describe "adding modules" do
57
- it "should accept Forge modules with a string arg" do
58
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, '1.2.3', anything).and_call_original
59
-
60
- expect { subject.add_module('puppet/test_module', '1.2.3') }.to change { subject.modules }
61
- expect(subject.modules.collect(&:name)).to include('test_module')
62
- end
63
-
64
- it "should not accept Forge modules with a version comparison" do
65
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, '< 1.2.0', anything).and_call_original
66
-
67
- expect {
68
- subject.add_module('puppet/test_module', '< 1.2.0')
69
- }.to raise_error(RuntimeError, /module puppet\/test_module.*doesn't have an implementation/i)
70
-
71
- expect(subject.modules.collect(&:name)).not_to include('test_module')
72
- end
73
-
74
- it "should accept non-Forge modules with a hash arg" do
75
- module_opts = { git: 'git@example.com:puppet/test_module.git' }
70
+ describe "loading a Puppetfile" do
71
+ context 'using load' do
72
+ it "returns the loaded content" do
73
+ path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
74
+ subject = described_class.new(path, {})
76
75
 
77
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, module_opts, anything).and_call_original
76
+ loaded_content = subject.load
77
+ expect(loaded_content).to be_an_instance_of(Hash)
78
78
 
79
- expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
80
- expect(subject.modules.collect(&:name)).to include('test_module')
81
- end
82
-
83
- it "should accept non-Forge modules with a valid relative :install_path option" do
84
- module_opts = {
85
- install_path: 'vendor',
86
- git: 'git@example.com:puppet/test_module.git',
87
- }
88
-
89
- allow(R10K::Module).to receive(:new).with('puppet/test_module', File.join(subject.basedir, 'vendor'), module_opts, anything).and_call_original
90
-
91
- expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
92
- expect(subject.modules.collect(&:name)).to include('test_module')
93
- end
94
-
95
- it "should accept non-Forge modules with a valid absolute :install_path option" do
96
- install_path = File.join(subject.basedir, 'vendor')
97
-
98
- module_opts = {
99
- install_path: install_path,
100
- git: 'git@example.com:puppet/test_module.git',
101
- }
102
-
103
- allow(R10K::Module).to receive(:new).with('puppet/test_module', install_path, module_opts, anything).and_call_original
104
-
105
- expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
106
- expect(subject.modules.collect(&:name)).to include('test_module')
107
- end
108
-
109
- it "should reject non-Forge modules with an invalid relative :install_path option" do
110
- module_opts = {
111
- install_path: '../../vendor',
112
- git: 'git@example.com:puppet/test_module.git',
113
- }
114
-
115
- allow(R10K::Module).to receive(:new).with('puppet/test_module', File.join(subject.basedir, 'vendor'), module_opts, anything).and_call_original
116
-
117
- expect { subject.add_module('puppet/test_module', module_opts) }.to raise_error(R10K::Error, /cannot manage content.*is not within/i).and not_change { subject.modules }
118
- end
119
-
120
- it "should reject non-Forge modules with an invalid absolute :install_path option" do
121
- module_opts = {
122
- install_path: '/tmp/mydata/vendor',
123
- git: 'git@example.com:puppet/test_module.git',
124
- }
79
+ has_some_data = loaded_content.values.none?(&:empty?)
80
+ expect(has_some_data).to be true
81
+ end
125
82
 
126
- allow(R10K::Module).to receive(:new).with('puppet/test_module', File.join(subject.basedir, 'vendor'), module_opts, anything).and_call_original
83
+ it "is idempotent" do
84
+ path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
85
+ subject = described_class.new(path, {})
127
86
 
128
- expect { subject.add_module('puppet/test_module', module_opts) }.to raise_error(R10K::Error, /cannot manage content.*is not within/i).and not_change { subject.modules }
129
- end
87
+ expect(subject.loader).to receive(:load).and_call_original.once
130
88
 
131
- it "should disable and not add modules that conflict with the environment" do
132
- env = instance_double('R10K::Environment::Base')
133
- mod = instance_double('R10K::Module::Base', name: 'conflict', origin: :puppetfile)
134
- allow(mod).to receive(:origin=).and_return(nil)
135
- allow(subject).to receive(:environment).and_return(env)
136
- allow(env).to receive(:'module_conflicts?').with(mod).and_return(true)
89
+ loaded_content1 = subject.load
90
+ expect(subject.loaded?).to be true
91
+ loaded_content2 = subject.load
137
92
 
138
- allow(R10K::Module).to receive(:new).with('test', anything, anything, anything).and_return(mod)
139
- expect { subject.add_module('test', {}) }.not_to change { subject.modules }
140
- end
141
- end
142
-
143
- describe "#purge_exclusions" do
144
- let(:managed_dirs) { ['dir1', 'dir2'] }
93
+ expect(loaded_content2).to eq(loaded_content1)
94
+ end
145
95
 
146
- before(:each) do
147
- allow(subject).to receive(:managed_directories).and_return(managed_dirs)
96
+ it "returns nil if Puppetfile doesn't exist" do
97
+ path = '/rando/path/that/wont/exist'
98
+ subject = described_class.new(path, {})
99
+ expect(subject.load).to eq nil
100
+ end
148
101
  end
149
102
 
150
- it "includes managed_directories" do
151
- expect(subject.purge_exclusions).to match_array(managed_dirs)
152
- end
103
+ context 'using load!' do
104
+ it "returns the loaded content" do
105
+ path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
106
+ subject = described_class.new(path, {})
153
107
 
154
- context "when belonging to an environment" do
155
- let(:env_contents) { ['env1', 'env2' ] }
108
+ loaded_content = subject.load!
109
+ expect(loaded_content).to be_an_instance_of(Hash)
156
110
 
157
- before(:each) do
158
- mock_env = double(:environment, desired_contents: env_contents)
159
- allow(subject).to receive(:environment).and_return(mock_env)
111
+ has_some_data = loaded_content.values.none?(&:empty?)
112
+ expect(has_some_data).to be true
160
113
  end
161
114
 
162
- it "includes environment's desired_contents" do
163
- expect(subject.purge_exclusions).to match_array(managed_dirs + env_contents)
115
+ it "raises if Puppetfile doesn't exist" do
116
+ path = '/rando/path/that/wont/exist'
117
+ subject = described_class.new(path, {})
118
+ expect {
119
+ subject.load!
120
+ }.to raise_error(/No such file or directory.*\/rando\/path\/.*/)
164
121
  end
165
122
  end
166
123
  end
167
124
 
168
- describe '#managed_directories' do
169
- it 'returns an array of paths that can be purged' do
170
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, '1.2.3', anything).and_call_original
125
+ describe 'default_branch_override' do
126
+ it 'is passed correctly to module loader init' do
127
+ # This path doesn't matter so long as it has a Puppetfile within it
128
+ path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
129
+ subject = described_class.new(path, {overrides: {environments: {default_branch_override: 'foo'}}})
171
130
 
172
- subject.add_module('puppet/test_module', '1.2.3')
173
- expect(subject.managed_directories).to match_array(["/some/nonexistent/basedir/modules"])
174
- end
131
+ repo = instance_double('R10K::Git::StatefulRepository')
132
+ allow(repo).to receive(:resolve).with('foo').and_return(true)
133
+ allow(R10K::Git::StatefulRepository).to receive(:new).and_return(repo)
175
134
 
176
- context 'with a module with install_path == \'\'' do
177
- it 'basedir isn\'t in the list of paths to purge' do
178
- module_opts = { install_path: '', git: 'git@example.com:puppet/test_module.git' }
135
+ allow(subject.loader).to receive(:puppetfile_content).and_return <<-EOPF
136
+ # Track control branch and fall-back to main if no matching branch.
137
+ mod 'hieradata',
138
+ :git => 'git@git.example.com:organization/hieradata.git',
139
+ :branch => :control_branch,
140
+ :default_branch => 'main'
141
+ EOPF
179
142
 
180
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.basedir, module_opts, anything).and_call_original
143
+ expect(subject.logger).not_to receive(:warn).
144
+ with(/Mismatch between passed and initialized.*preferring passed value/)
181
145
 
182
- subject.add_module('puppet/test_module', module_opts)
183
- expect(subject.managed_directories).to be_empty
184
- end
185
- end
186
- end
146
+ subject.load
187
147
 
188
- describe "evaluating a Puppetfile" do
189
- def expect_wrapped_error(orig, pf_path, wrapped_error)
190
- expect(orig).to be_a_kind_of(R10K::Error)
191
- expect(orig.message).to eq("Failed to evaluate #{pf_path}")
192
- expect(orig.original).to be_a_kind_of(wrapped_error)
148
+ loaded_module = subject.modules.first
149
+ expect(loaded_module.version).to eq('foo')
193
150
  end
194
151
 
195
- it "wraps and re-raises syntax errors" do
196
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'invalid-syntax')
197
- pf_path = File.join(path, 'Puppetfile')
198
- subject = described_class.new(path)
199
- expect {
200
- subject.load!
201
- }.to raise_error do |e|
202
- expect_wrapped_error(e, pf_path, SyntaxError)
203
- end
204
- end
152
+ it 'overrides module loader init if needed' do
153
+ # This path doesn't matter so long as it has a Puppetfile within it
154
+ path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
155
+ subject = described_class.new(path, {overrides: {environments: {default_branch_override: 'foo'}}})
205
156
 
206
- it "wraps and re-raises load errors" do
207
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'load-error')
208
- pf_path = File.join(path, 'Puppetfile')
209
- subject = described_class.new(path)
210
- expect {
211
- subject.load!
212
- }.to raise_error do |e|
213
- expect_wrapped_error(e, pf_path, LoadError)
214
- end
215
- end
157
+ repo = instance_double('R10K::Git::StatefulRepository')
158
+ allow(repo).to receive(:resolve).with('bar').and_return(true)
159
+ allow(R10K::Git::StatefulRepository).to receive(:new).and_return(repo)
216
160
 
217
- it "wraps and re-raises argument errors" do
218
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'argument-error')
219
- pf_path = File.join(path, 'Puppetfile')
220
- subject = described_class.new(path)
221
- expect {
222
- subject.load!
223
- }.to raise_error do |e|
224
- expect_wrapped_error(e, pf_path, ArgumentError)
225
- end
226
- end
161
+ allow(subject.loader).to receive(:puppetfile_content).and_return <<-EOPF
162
+ # Track control branch and fall-back to main if no matching branch.
163
+ mod 'hieradata',
164
+ :git => 'git@git.example.com:organization/hieradata.git',
165
+ :branch => :control_branch,
166
+ :default_branch => 'main'
167
+ EOPF
227
168
 
228
- it "rejects Puppetfiles with duplicate module names" do
229
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'duplicate-module-error')
230
- pf_path = File.join(path, 'Puppetfile')
231
- subject = described_class.new(path)
232
- expect {
233
- subject.load!
234
- }.to raise_error(R10K::Error, /Puppetfiles cannot contain duplicate module names/i)
235
- end
169
+ expect(subject.logger).to receive(:warn).
170
+ with(/Mismatch between passed and initialized.*preferring passed value/)
236
171
 
237
- it "wraps and re-raises name errors" do
238
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'name-error')
239
- pf_path = File.join(path, 'Puppetfile')
240
- subject = described_class.new(path)
241
- expect {
242
- subject.load!
243
- }.to raise_error do |e|
244
- expect_wrapped_error(e, pf_path, NameError)
245
- end
172
+ subject.load('bar')
173
+ loaded_module = subject.modules.first
174
+ expect(loaded_module.version).to eq('bar')
246
175
  end
247
176
 
248
- it "accepts a forge module with a version" do
177
+ it 'does not warn if passed and initialized default_branch_overrides match' do
178
+ # This path doesn't matter so long as it has a Puppetfile within it
249
179
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
250
- pf_path = File.join(path, 'Puppetfile')
251
- subject = described_class.new(path)
252
- expect { subject.load! }.not_to raise_error
253
- end
180
+ subject = described_class.new(path, {overrides: {environments: {default_branch_override: 'foo'}}})
254
181
 
255
- it "accepts a forge module without a version" do
256
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-without-version')
257
- pf_path = File.join(path, 'Puppetfile')
258
- subject = described_class.new(path)
259
- expect { subject.load! }.not_to raise_error
260
- end
182
+ repo = instance_double('R10K::Git::StatefulRepository')
183
+ allow(repo).to receive(:resolve).with('foo').and_return(true)
184
+ allow(R10K::Git::StatefulRepository).to receive(:new).and_return(repo)
261
185
 
262
- it "creates a git module and applies the default branch sepcified in the Puppetfile" do
263
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
264
- pf_path = File.join(path, 'Puppetfile')
265
- subject = described_class.new(path)
266
- expect { subject.load! }.not_to raise_error
267
- git_module = subject.modules[0]
268
- expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
269
- end
186
+ allow(subject.loader).to receive(:puppetfile_content).and_return <<-EOPF
187
+ # Track control branch and fall-back to main if no matching branch.
188
+ mod 'hieradata',
189
+ :git => 'git@git.example.com:organization/hieradata.git',
190
+ :branch => :control_branch,
191
+ :default_branch => 'main'
192
+ EOPF
193
+
194
+ expect(subject.logger).not_to receive(:warn).
195
+ with(/Mismatch between passed and initialized.*preferring passed value/)
270
196
 
271
- it "creates a git module and applies the provided default_branch_override" do
272
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
273
- pf_path = File.join(path, 'Puppetfile')
274
- subject = described_class.new(path)
275
- default_branch_override = 'default_branch_override_name'
276
- expect { subject.load!(default_branch_override) }.not_to raise_error
277
- git_module = subject.modules[0]
278
- expect(git_module.default_override_ref).to eq default_branch_override
279
- expect(git_module.default_ref).to eq "here_lies_the_default_branch"
197
+ subject.load('foo')
198
+ loaded_module = subject.modules.first
199
+ expect(loaded_module.version).to eq('foo')
280
200
  end
281
201
  end
282
202
 
@@ -287,7 +207,7 @@ describe R10K::Puppetfile do
287
207
  subject.accept(visitor)
288
208
  end
289
209
 
290
- it "passes the visitor to each module if the visitor yields" do
210
+ it "synchronizes each module if the visitor yields" do
291
211
  visitor = spy('visitor')
292
212
  expect(visitor).to receive(:visit) do |type, other, &block|
293
213
  expect(type).to eq :puppetfile
@@ -297,8 +217,8 @@ describe R10K::Puppetfile do
297
217
 
298
218
  mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
299
219
  mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
300
- expect(mod1).to receive(:accept).with(visitor)
301
- expect(mod2).to receive(:accept).with(visitor)
220
+ expect(mod1).to receive(:sync)
221
+ expect(mod2).to receive(:sync)
302
222
  expect(subject).to receive(:modules).and_return([mod1, mod2])
303
223
 
304
224
  subject.accept(visitor)
@@ -318,8 +238,8 @@ describe R10K::Puppetfile do
318
238
 
319
239
  mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
320
240
  mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
321
- expect(mod1).to receive(:accept).with(visitor)
322
- expect(mod2).to receive(:accept).with(visitor)
241
+ expect(mod1).to receive(:sync)
242
+ expect(mod2).to receive(:sync)
323
243
  expect(subject).to receive(:modules).and_return([mod1, mod2])
324
244
 
325
245
  expect(Thread).to receive(:new).exactly(pool_size).and_call_original
@@ -343,9 +263,9 @@ describe R10K::Puppetfile do
343
263
  m5 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
344
264
  m6 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
345
265
 
346
- expect(subject).to receive(:modules).and_return([m1, m2, m3, m4, m5, m6])
266
+ modules = [m1, m2, m3, m4, m5, m6]
347
267
 
348
- queue = subject.modules_queue(visitor)
268
+ queue = R10K::ContentSynchronizer.modules_visit_queue(modules, visitor, subject)
349
269
  expect(queue.length).to be 4
350
270
  queue_array = 4.times.map { queue.pop }
351
271
  expect(queue_array).to match_array([[m1], [m2], [m3, m4], [m5, m6]])