r10k 3.9.0 → 3.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +1 -1
  3. data/.github/workflows/stale.yml +19 -0
  4. data/CHANGELOG.mkd +5 -0
  5. data/doc/dynamic-environments/configuration.mkd +6 -6
  6. data/lib/r10k/action/base.rb +8 -1
  7. data/lib/r10k/action/deploy/display.rb +39 -9
  8. data/lib/r10k/action/deploy/environment.rb +63 -40
  9. data/lib/r10k/action/deploy/module.rb +47 -28
  10. data/lib/r10k/action/puppetfile/check.rb +3 -1
  11. data/lib/r10k/action/puppetfile/install.rb +20 -23
  12. data/lib/r10k/action/puppetfile/purge.rb +8 -2
  13. data/lib/r10k/content_synchronizer.rb +83 -0
  14. data/lib/r10k/deployment.rb +1 -1
  15. data/lib/r10k/environment/base.rb +21 -1
  16. data/lib/r10k/environment/git.rb +0 -3
  17. data/lib/r10k/environment/svn.rb +4 -6
  18. data/lib/r10k/environment/with_modules.rb +18 -10
  19. data/lib/r10k/module.rb +1 -1
  20. data/lib/r10k/module/base.rb +17 -1
  21. data/lib/r10k/module/forge.rb +24 -18
  22. data/lib/r10k/module/git.rb +22 -13
  23. data/lib/r10k/module/local.rb +1 -0
  24. data/lib/r10k/module/svn.rb +11 -8
  25. data/lib/r10k/puppetfile.rb +55 -70
  26. data/lib/r10k/source/base.rb +4 -0
  27. data/lib/r10k/source/git.rb +14 -6
  28. data/lib/r10k/source/hash.rb +1 -3
  29. data/lib/r10k/source/svn.rb +0 -2
  30. data/lib/r10k/util/cleaner.rb +21 -0
  31. data/lib/r10k/version.rb +1 -1
  32. data/locales/r10k.pot +51 -59
  33. data/spec/r10k-mocks/mock_source.rb +1 -1
  34. data/spec/shared-examples/puppetfile-action.rb +7 -7
  35. data/spec/unit/action/deploy/display_spec.rb +32 -6
  36. data/spec/unit/action/deploy/environment_spec.rb +76 -48
  37. data/spec/unit/action/deploy/module_spec.rb +139 -31
  38. data/spec/unit/action/puppetfile/check_spec.rb +2 -2
  39. data/spec/unit/action/puppetfile/install_spec.rb +31 -10
  40. data/spec/unit/action/puppetfile/purge_spec.rb +25 -5
  41. data/spec/unit/module/forge_spec.rb +15 -13
  42. data/spec/unit/module/git_spec.rb +8 -0
  43. data/spec/unit/module_spec.rb +5 -5
  44. data/spec/unit/puppetfile_spec.rb +40 -26
  45. data/spec/unit/util/purgeable_spec.rb +2 -8
  46. metadata +5 -2
@@ -11,7 +11,7 @@ describe R10K::Action::Puppetfile::Check do
11
11
  end
12
12
 
13
13
  before(:each) do
14
- allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil).and_return(puppetfile)
14
+ allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", {moduledir: nil, puppetfile_path: nil}).and_return(puppetfile)
15
15
  end
16
16
 
17
17
  it_behaves_like "a puppetfile action"
@@ -34,7 +34,7 @@ describe R10K::Action::Puppetfile::Check do
34
34
  it "respects --puppetfile option" do
35
35
  allow($stderr).to receive(:puts)
36
36
 
37
- expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, "/custom/puppetfile/path").and_return(puppetfile)
37
+ expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", {moduledir: nil, puppetfile_path: "/custom/puppetfile/path"}).and_return(puppetfile)
38
38
 
39
39
  checker({puppetfile: "/custom/puppetfile/path"}).call
40
40
  end
@@ -2,8 +2,11 @@ require 'spec_helper'
2
2
  require 'r10k/action/puppetfile/install'
3
3
 
4
4
  describe R10K::Action::Puppetfile::Install do
5
- let(:default_opts) { {root: "/some/nonexistent/path"} }
6
- let(:puppetfile) { R10K::Puppetfile.new('/some/nonexistent/path', nil, nil) }
5
+ let(:default_opts) { { root: "/some/nonexistent/path" } }
6
+ let(:puppetfile) {
7
+ R10K::Puppetfile.new('/some/nonexistent/path',
8
+ {:moduledir => nil, :puppetfile_path => nil, :force => false})
9
+ }
7
10
 
8
11
  def installer(opts = {}, argv = [], settings = {})
9
12
  opts = default_opts.merge(opts)
@@ -12,7 +15,10 @@ describe R10K::Action::Puppetfile::Install do
12
15
 
13
16
  before(:each) do
14
17
  allow(puppetfile).to receive(:load!).and_return(nil)
15
- allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil, nil, nil).and_return(puppetfile)
18
+ allow(R10K::Puppetfile).to receive(:new).
19
+ with("/some/nonexistent/path",
20
+ {:moduledir => nil, :puppetfile_path => nil, :force => false}).
21
+ and_return(puppetfile)
16
22
  end
17
23
 
18
24
  it_behaves_like "a puppetfile install action"
@@ -20,12 +26,11 @@ describe R10K::Action::Puppetfile::Install do
20
26
  describe "installing modules" do
21
27
  let(:modules) do
22
28
  (1..4).map do |idx|
23
- R10K::Module::Base.new("author/modname#{idx}", "/some/nonexistent/path/modname#{idx}", nil)
29
+ R10K::Module::Base.new("author/modname#{idx}", "/some/nonexistent/path/modname#{idx}", {})
24
30
  end
25
31
  end
26
32
 
27
33
  before do
28
- allow(puppetfile).to receive(:purge!)
29
34
  allow(puppetfile).to receive(:modules).and_return(modules)
30
35
  allow(puppetfile).to receive(:modules_by_vcs_cachedir).and_return({none: modules})
31
36
  end
@@ -50,7 +55,15 @@ describe R10K::Action::Puppetfile::Install do
50
55
  end
51
56
 
52
57
  it "purges the moduledir after installation" do
53
- expect(puppetfile).to receive(:purge!)
58
+ mock_cleaner = double("cleaner")
59
+ allow(puppetfile).to receive(:desired_contents).and_return(["root/foo"])
60
+ allow(puppetfile).to receive(:managed_directories).and_return(["root"])
61
+ allow(puppetfile).to receive(:purge_exclusions).and_return(["root/**/**.rb"])
62
+
63
+ expect(R10K::Util::Cleaner).to receive(:new).
64
+ with(["root"], ["root/foo"], ["root/**/**.rb"]).
65
+ and_return(mock_cleaner)
66
+ expect(mock_cleaner).to receive(:purge!)
54
67
 
55
68
  installer.call
56
69
  end
@@ -58,13 +71,19 @@ describe R10K::Action::Puppetfile::Install do
58
71
 
59
72
  describe "using custom paths" do
60
73
  it "can use a custom puppetfile path" do
61
- expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, "/some/other/path/Puppetfile", nil, nil).and_return(puppetfile)
74
+ expect(R10K::Puppetfile).to receive(:new).
75
+ with("/some/nonexistent/path",
76
+ {:moduledir => nil, :force => false, puppetfile_path: "/some/other/path/Puppetfile"}).
77
+ and_return(puppetfile)
62
78
 
63
79
  installer({puppetfile: "/some/other/path/Puppetfile"}).call
64
80
  end
65
81
 
66
82
  it "can use a custom moduledir path" do
67
- expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", "/some/other/path/site-modules", nil, nil, nil).and_return(puppetfile)
83
+ expect(R10K::Puppetfile).to receive(:new).
84
+ with("/some/nonexistent/path",
85
+ {:puppetfile_path => nil, :force => false, moduledir: "/some/other/path/site-modules"}).
86
+ and_return(puppetfile)
68
87
 
69
88
  installer({moduledir: "/some/other/path/site-modules"}).call
70
89
  end
@@ -76,8 +95,10 @@ describe R10K::Action::Puppetfile::Install do
76
95
  end
77
96
 
78
97
  it "can use the force overwrite option" do
79
- subject = described_class.new({root: "/some/nonexistent/path", force: true}, [])
80
- expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil, nil, true).and_return(puppetfile)
98
+ subject = described_class.new({root: "/some/nonexistent/path", force: true}, [], {})
99
+ expect(R10K::Puppetfile).to receive(:new).
100
+ with("/some/nonexistent/path", {:moduledir => nil, :puppetfile_path => nil, :force => true}).
101
+ and_return(puppetfile)
81
102
  subject.call
82
103
  end
83
104
 
@@ -3,7 +3,13 @@ require 'r10k/action/puppetfile/purge'
3
3
 
4
4
  describe R10K::Action::Puppetfile::Purge do
5
5
  let(:default_opts) { {root: "/some/nonexistent/path"} }
6
- let(:puppetfile) { instance_double('R10K::Puppetfile', :load! => nil) }
6
+ let(:puppetfile) do
7
+ instance_double('R10K::Puppetfile',
8
+ :load! => nil,
9
+ :managed_directories => %w{foo},
10
+ :desired_contents => %w{bar},
11
+ :purge_exclusions => %w{baz})
12
+ end
7
13
 
8
14
  def purger(opts = {}, argv = [], settings = {})
9
15
  opts = default_opts.merge(opts)
@@ -11,13 +17,21 @@ describe R10K::Action::Puppetfile::Purge do
11
17
  end
12
18
 
13
19
  before(:each) do
14
- allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil).and_return(puppetfile)
20
+ allow(R10K::Puppetfile).to receive(:new).
21
+ with("/some/nonexistent/path", {moduledir: nil, puppetfile_path: nil}).
22
+ and_return(puppetfile)
15
23
  end
16
24
 
17
25
  it_behaves_like "a puppetfile action"
18
26
 
19
27
  it "purges unmanaged entries in the Puppetfile moduledir" do
20
- expect(puppetfile).to receive(:purge!)
28
+ mock_cleaner = double("cleaner")
29
+
30
+ expect(R10K::Util::Cleaner).to receive(:new).
31
+ with(["foo"], ["bar"], ["baz"]).
32
+ and_return(mock_cleaner)
33
+
34
+ expect(mock_cleaner).to receive(:purge!)
21
35
 
22
36
  purger.call
23
37
  end
@@ -28,13 +42,19 @@ describe R10K::Action::Puppetfile::Purge do
28
42
  end
29
43
 
30
44
  it "can use a custom puppetfile path" do
31
- expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, "/some/other/path/Puppetfile").and_return(puppetfile)
45
+ expect(R10K::Puppetfile).to receive(:new).
46
+ with("/some/nonexistent/path",
47
+ {moduledir: nil, puppetfile_path: "/some/other/path/Puppetfile"}).
48
+ and_return(puppetfile)
32
49
 
33
50
  purger({puppetfile: "/some/other/path/Puppetfile"}).call
34
51
  end
35
52
 
36
53
  it "can use a custom moduledir path" do
37
- expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", "/some/other/path/site-modules", nil).and_return(puppetfile)
54
+ expect(R10K::Puppetfile).to receive(:new).
55
+ with("/some/nonexistent/path",
56
+ {moduledir: "/some/other/path/site-modules", puppetfile_path: nil}).
57
+ and_return(puppetfile)
38
58
 
39
59
  purger({moduledir: "/some/other/path/site-modules"}).call
40
60
  end
@@ -11,15 +11,15 @@ describe R10K::Module::Forge do
11
11
 
12
12
  describe "implementing the Puppetfile spec" do
13
13
  it "should implement 'branan/eight_hundred', '8.0.0'" do
14
- expect(described_class).to be_implement('branan/eight_hundred', '8.0.0')
14
+ expect(described_class).to be_implement('branan/eight_hundred', { version: '8.0.0' })
15
15
  end
16
16
 
17
17
  it "should implement 'branan-eight_hundred', '8.0.0'" do
18
- expect(described_class).to be_implement('branan-eight_hundred', '8.0.0')
18
+ expect(described_class).to be_implement('branan-eight_hundred', { version: '8.0.0' })
19
19
  end
20
20
 
21
21
  it "should fail with an invalid title" do
22
- expect(described_class).to_not be_implement('branan!eight_hundred', '8.0.0')
22
+ expect(described_class).to_not be_implement('branan!eight_hundred', { version: '8.0.0' })
23
23
  end
24
24
  end
25
25
 
@@ -30,7 +30,7 @@ describe R10K::Module::Forge do
30
30
  end
31
31
 
32
32
  describe "setting attributes" do
33
- subject { described_class.new('branan/eight_hundred', '/moduledir', '8.0.0') }
33
+ subject { described_class.new('branan/eight_hundred', '/moduledir', { version: '8.0.0' }) }
34
34
 
35
35
  it "sets the name" do
36
36
  expect(subject.name).to eq 'eight_hundred'
@@ -50,7 +50,7 @@ describe R10K::Module::Forge do
50
50
  end
51
51
 
52
52
  describe "properties" do
53
- subject { described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0') }
53
+ subject { described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' }) }
54
54
 
55
55
  it "sets the module type to :forge" do
56
56
  expect(subject.properties).to include(:type => :forge)
@@ -67,7 +67,7 @@ describe R10K::Module::Forge do
67
67
  end
68
68
 
69
69
  context "when a module is deprecated" do
70
- subject { described_class.new('puppetlabs/corosync', fixture_modulepath, :latest) }
70
+ subject { described_class.new('puppetlabs/corosync', fixture_modulepath, { version: :latest }) }
71
71
 
72
72
  it "warns on sync if module is not already insync" do
73
73
  allow(subject).to receive(:status).and_return(:absent)
@@ -77,6 +77,7 @@ describe R10K::Module::Forge do
77
77
  logger_dbl = double(Log4r::Logger)
78
78
  allow_any_instance_of(described_class).to receive(:logger).and_return(logger_dbl)
79
79
 
80
+ allow(logger_dbl).to receive(:info).with(/Deploying module to.*/)
80
81
  expect(logger_dbl).to receive(:warn).with(/puppet forge module.*puppetlabs-corosync.*has been deprecated/i)
81
82
 
82
83
  subject.sync
@@ -88,6 +89,7 @@ describe R10K::Module::Forge do
88
89
  logger_dbl = double(Log4r::Logger)
89
90
  allow_any_instance_of(described_class).to receive(:logger).and_return(logger_dbl)
90
91
 
92
+ allow(logger_dbl).to receive(:info).with(/Deploying module to.*/)
91
93
  expect(logger_dbl).to_not receive(:warn).with(/puppet forge module.*puppetlabs-corosync.*has been deprecated/i)
92
94
 
93
95
  subject.sync
@@ -96,12 +98,12 @@ describe R10K::Module::Forge do
96
98
 
97
99
  describe '#expected_version' do
98
100
  it "returns an explicitly given expected version" do
99
- subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
101
+ subject = described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' })
100
102
  expect(subject.expected_version).to eq '8.0.0'
101
103
  end
102
104
 
103
105
  it "uses the latest version from the forge when the version is :latest" do
104
- subject = described_class.new('branan/eight_hundred', fixture_modulepath, :latest)
106
+ subject = described_class.new('branan/eight_hundred', fixture_modulepath, { version: :latest })
105
107
  expect(subject.v3_module).to receive_message_chain(:current_release, :version).and_return('8.8.8')
106
108
  expect(subject.expected_version).to eq '8.8.8'
107
109
  end
@@ -109,7 +111,7 @@ describe R10K::Module::Forge do
109
111
 
110
112
  describe "determining the status" do
111
113
 
112
- subject { described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0') }
114
+ subject { described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' }) }
113
115
 
114
116
  it "is :absent if the module directory is absent" do
115
117
  allow(subject).to receive(:exist?).and_return false
@@ -154,7 +156,7 @@ describe R10K::Module::Forge do
154
156
  end
155
157
 
156
158
  describe "#sync" do
157
- subject { described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0') }
159
+ subject { described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' }) }
158
160
 
159
161
  it 'does nothing when the module is in sync' do
160
162
  allow(subject).to receive(:status).and_return :insync
@@ -186,7 +188,7 @@ describe R10K::Module::Forge do
186
188
 
187
189
  describe '#install' do
188
190
  it 'installs the module from the forge' do
189
- subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
191
+ subject = described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' })
190
192
  release = instance_double('R10K::Forge::ModuleRelease')
191
193
  expect(R10K::Forge::ModuleRelease).to receive(:new).with('branan-eight_hundred', '8.0.0').and_return(release)
192
194
  expect(release).to receive(:install).with(subject.path)
@@ -196,7 +198,7 @@ describe R10K::Module::Forge do
196
198
 
197
199
  describe '#uninstall' do
198
200
  it 'removes the module path' do
199
- subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
201
+ subject = described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' })
200
202
  expect(FileUtils).to receive(:rm_rf).with(subject.path.to_s)
201
203
  subject.uninstall
202
204
  end
@@ -204,7 +206,7 @@ describe R10K::Module::Forge do
204
206
 
205
207
  describe '#reinstall' do
206
208
  it 'uninstalls and then installs the module' do
207
- subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
209
+ subject = described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' })
208
210
  expect(subject).to receive(:uninstall)
209
211
  expect(subject).to receive(:install)
210
212
  subject.reinstall
@@ -210,6 +210,14 @@ describe R10K::Module::Git do
210
210
  expect(mod.desired_ref).to eq(:control_branch)
211
211
  end
212
212
 
213
+ it "warns control branch may be unresolvable" do
214
+ logger = double("logger")
215
+ allow_any_instance_of(described_class).to receive(:logger).and_return(logger)
216
+ expect(logger).to receive(:warn).with(/Cannot track control repo branch.*boolean.*/)
217
+
218
+ test_module(branch: :control_branch)
219
+ end
220
+
213
221
  context "when default ref is provided and resolvable" do
214
222
  it "uses default ref" do
215
223
  expect(mock_repo).to receive(:resolve).with('default').and_return('abc123')
@@ -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,7 @@ 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
79
  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
@@ -54,15 +68,15 @@ describe R10K::Puppetfile do
54
68
  end
55
69
 
56
70
  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
71
+ it "should transform Forge modules with a string arg to have a version key" do
72
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
59
73
 
60
74
  expect { subject.add_module('puppet/test_module', '1.2.3') }.to change { subject.modules }
61
75
  expect(subject.modules.collect(&:name)).to include('test_module')
62
76
  end
63
77
 
64
78
  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
79
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '< 1.2.0'), anything).and_call_original
66
80
 
67
81
  expect {
68
82
  subject.add_module('puppet/test_module', '< 1.2.0')
@@ -167,7 +181,7 @@ describe R10K::Puppetfile do
167
181
 
168
182
  describe '#managed_directories' do
169
183
  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
184
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
171
185
 
172
186
  subject.add_module('puppet/test_module', '1.2.3')
173
187
  expect(subject.managed_directories).to match_array(["/some/nonexistent/basedir/modules"])
@@ -195,7 +209,7 @@ describe R10K::Puppetfile do
195
209
  it "wraps and re-raises syntax errors" do
196
210
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'invalid-syntax')
197
211
  pf_path = File.join(path, 'Puppetfile')
198
- subject = described_class.new(path)
212
+ subject = described_class.new(path, {})
199
213
  expect {
200
214
  subject.load!
201
215
  }.to raise_error do |e|
@@ -206,7 +220,7 @@ describe R10K::Puppetfile do
206
220
  it "wraps and re-raises load errors" do
207
221
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'load-error')
208
222
  pf_path = File.join(path, 'Puppetfile')
209
- subject = described_class.new(path)
223
+ subject = described_class.new(path, {})
210
224
  expect {
211
225
  subject.load!
212
226
  }.to raise_error do |e|
@@ -217,7 +231,7 @@ describe R10K::Puppetfile do
217
231
  it "wraps and re-raises argument errors" do
218
232
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'argument-error')
219
233
  pf_path = File.join(path, 'Puppetfile')
220
- subject = described_class.new(path)
234
+ subject = described_class.new(path, {})
221
235
  expect {
222
236
  subject.load!
223
237
  }.to raise_error do |e|
@@ -228,7 +242,7 @@ describe R10K::Puppetfile do
228
242
  it "rejects Puppetfiles with duplicate module names" do
229
243
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'duplicate-module-error')
230
244
  pf_path = File.join(path, 'Puppetfile')
231
- subject = described_class.new(path)
245
+ subject = described_class.new(path, {})
232
246
  expect {
233
247
  subject.load!
234
248
  }.to raise_error(R10K::Error, /Puppetfiles cannot contain duplicate module names/i)
@@ -237,7 +251,7 @@ describe R10K::Puppetfile do
237
251
  it "wraps and re-raises name errors" do
238
252
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'name-error')
239
253
  pf_path = File.join(path, 'Puppetfile')
240
- subject = described_class.new(path)
254
+ subject = described_class.new(path, {})
241
255
  expect {
242
256
  subject.load!
243
257
  }.to raise_error do |e|
@@ -248,21 +262,21 @@ describe R10K::Puppetfile do
248
262
  it "accepts a forge module with a version" do
249
263
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
250
264
  pf_path = File.join(path, 'Puppetfile')
251
- subject = described_class.new(path)
265
+ subject = described_class.new(path, {})
252
266
  expect { subject.load! }.not_to raise_error
253
267
  end
254
268
 
255
269
  it "accepts a forge module without a version" do
256
270
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-without-version')
257
271
  pf_path = File.join(path, 'Puppetfile')
258
- subject = described_class.new(path)
272
+ subject = described_class.new(path, {})
259
273
  expect { subject.load! }.not_to raise_error
260
274
  end
261
275
 
262
276
  it "creates a git module and applies the default branch sepcified in the Puppetfile" do
263
277
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
264
278
  pf_path = File.join(path, 'Puppetfile')
265
- subject = described_class.new(path)
279
+ subject = described_class.new(path, {})
266
280
  expect { subject.load! }.not_to raise_error
267
281
  git_module = subject.modules[0]
268
282
  expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
@@ -271,7 +285,7 @@ describe R10K::Puppetfile do
271
285
  it "creates a git module and applies the provided default_branch_override" do
272
286
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
273
287
  pf_path = File.join(path, 'Puppetfile')
274
- subject = described_class.new(path)
288
+ subject = described_class.new(path, {})
275
289
  default_branch_override = 'default_branch_override_name'
276
290
  expect { subject.load!(default_branch_override) }.not_to raise_error
277
291
  git_module = subject.modules[0]
@@ -287,7 +301,7 @@ describe R10K::Puppetfile do
287
301
  subject.accept(visitor)
288
302
  end
289
303
 
290
- it "passes the visitor to each module if the visitor yields" do
304
+ it "synchronizes each module if the visitor yields" do
291
305
  visitor = spy('visitor')
292
306
  expect(visitor).to receive(:visit) do |type, other, &block|
293
307
  expect(type).to eq :puppetfile
@@ -297,8 +311,8 @@ describe R10K::Puppetfile do
297
311
 
298
312
  mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
299
313
  mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
300
- expect(mod1).to receive(:accept).with(visitor)
301
- expect(mod2).to receive(:accept).with(visitor)
314
+ expect(mod1).to receive(:sync)
315
+ expect(mod2).to receive(:sync)
302
316
  expect(subject).to receive(:modules).and_return([mod1, mod2])
303
317
 
304
318
  subject.accept(visitor)
@@ -318,8 +332,8 @@ describe R10K::Puppetfile do
318
332
 
319
333
  mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
320
334
  mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
321
- expect(mod1).to receive(:accept).with(visitor)
322
- expect(mod2).to receive(:accept).with(visitor)
335
+ expect(mod1).to receive(:sync)
336
+ expect(mod2).to receive(:sync)
323
337
  expect(subject).to receive(:modules).and_return([mod1, mod2])
324
338
 
325
339
  expect(Thread).to receive(:new).exactly(pool_size).and_call_original
@@ -343,9 +357,9 @@ describe R10K::Puppetfile do
343
357
  m5 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
344
358
  m6 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
345
359
 
346
- expect(subject).to receive(:modules).and_return([m1, m2, m3, m4, m5, m6])
360
+ modules = [m1, m2, m3, m4, m5, m6]
347
361
 
348
- queue = subject.modules_queue(visitor)
362
+ queue = R10K::ContentSynchronizer.modules_visit_queue(modules, visitor, subject)
349
363
  expect(queue.length).to be 4
350
364
  queue_array = 4.times.map { queue.pop }
351
365
  expect(queue_array).to match_array([[m1], [m2], [m3, m4], [m5, m6]])