r10k 2.6.9 → 3.0.0

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.
Files changed (83) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.travis.yml +9 -16
  4. data/CHANGELOG.mkd +23 -36
  5. data/Gemfile +2 -1
  6. data/MAINTAINERS +18 -0
  7. data/README.mkd +1 -5
  8. data/bin/r10k +2 -2
  9. data/doc/common-patterns.mkd +2 -2
  10. data/doc/dynamic-environments/configuration.mkd +1 -2
  11. data/doc/dynamic-environments/quickstart.mkd +3 -3
  12. data/doc/dynamic-environments/usage.mkd +0 -12
  13. data/doc/puppetfile.mkd +0 -18
  14. data/docker/Gemfile +13 -0
  15. data/docker/ci/build +72 -0
  16. data/docker/distelli-manifest.yml +4 -0
  17. data/docker/r10k/Dockerfile +41 -0
  18. data/docker/r10k/spec/dockerfile_spec.rb +16 -0
  19. data/integration/Gemfile +4 -2
  20. data/integration/Rakefile +3 -2
  21. data/integration/pre-suite/00_pe_install.rb +0 -1
  22. data/integration/pre-suite/30_test_utils.rb +17 -0
  23. data/integration/scripts/README.mkd +86 -0
  24. data/integration/scripts/setup_r10k_env_centos5.sh +23 -0
  25. data/integration/scripts/setup_r10k_env_centos6.sh +23 -0
  26. data/integration/scripts/setup_r10k_env_rhel7.sh +23 -0
  27. data/integration/scripts/setup_r10k_env_sles11.sh +23 -0
  28. data/integration/scripts/setup_r10k_env_sles12.sh +23 -0
  29. data/integration/scripts/setup_r10k_env_ubuntu1004.sh +23 -0
  30. data/integration/scripts/setup_r10k_env_ubuntu1204.sh +23 -0
  31. data/integration/scripts/setup_r10k_env_ubuntu1404.sh +23 -0
  32. data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +2 -2
  33. data/integration/tests/basic_functionality/negative/attempt_to_install_peonly_module_without_license.rb +71 -0
  34. data/integration/tests/basic_functionality/proxy_with_pe_only_module.rb +2 -2
  35. data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +2 -2
  36. data/integration/tests/i18n/deploy_module_with_unicode_in_file_name.rb +64 -0
  37. data/integration/tests/purging/does_not_purge_files_on_white_list.rb +93 -0
  38. data/integration/tests/purging/invalid_whitelist_types.rb +63 -0
  39. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +12 -2
  40. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +1 -8
  41. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +11 -2
  42. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +12 -2
  43. data/lib/r10k/action/deploy/environment.rb +2 -15
  44. data/lib/r10k/action/puppetfile/check.rb +1 -1
  45. data/lib/r10k/action/puppetfile/cri_runner.rb +1 -13
  46. data/lib/r10k/action/puppetfile/purge.rb +1 -1
  47. data/lib/r10k/cli/deploy.rb +0 -1
  48. data/lib/r10k/cli/puppetfile.rb +4 -0
  49. data/lib/r10k/environment/base.rb +7 -1
  50. data/lib/r10k/environment/svn.rb +1 -1
  51. data/lib/r10k/forge/module_release.rb +2 -2
  52. data/lib/r10k/git/rugged/base_repository.rb +6 -3
  53. data/lib/r10k/git/rugged/working_repository.rb +10 -1
  54. data/lib/r10k/git/shellgit/base_repository.rb +27 -8
  55. data/lib/r10k/git/shellgit/working_repository.rb +20 -6
  56. data/lib/r10k/git/stateful_repository.rb +0 -1
  57. data/lib/r10k/module/git.rb +0 -5
  58. data/lib/r10k/puppetfile.rb +22 -27
  59. data/lib/r10k/source/base.rb +6 -0
  60. data/lib/r10k/source/git.rb +2 -2
  61. data/lib/r10k/source/svn.rb +4 -2
  62. data/lib/r10k/util/purgeable.rb +4 -2
  63. data/lib/r10k/util/subprocess/runner/posix.rb +3 -3
  64. data/lib/r10k/version.rb +1 -4
  65. data/locales/r10k.pot +23 -19
  66. data/r10k.gemspec +4 -8
  67. data/r10k.yaml.example +6 -0
  68. data/spec/fixtures/unit/puppetfile/duplicate-module-error/Puppetfile +10 -0
  69. data/spec/fixtures/unit/puppetfile/name-error/Puppetfile +1 -0
  70. data/spec/shared-examples/git/working_repository.rb +46 -0
  71. data/spec/unit/action/deploy/environment_spec.rb +0 -63
  72. data/spec/unit/action/puppetfile/check_spec.rb +24 -9
  73. data/spec/unit/action/puppetfile/cri_runner_spec.rb +2 -20
  74. data/spec/unit/action/puppetfile/install_spec.rb +16 -16
  75. data/spec/unit/action/puppetfile/purge_spec.rb +29 -6
  76. data/spec/unit/forge/module_release_spec.rb +10 -6
  77. data/spec/unit/git/stateful_repository_spec.rb +1 -4
  78. data/spec/unit/puppetfile_spec.rb +43 -36
  79. metadata +33 -48
  80. data/.github/pull_request_template.md +0 -4
  81. data/.github/workflows/release.yml +0 -36
  82. data/CODEOWNERS +0 -1
  83. data/spec/fixtures/unit/puppetfile/default-branch-override/Puppetfile +0 -5
@@ -18,30 +18,26 @@ Gem::Specification.new do |s|
18
18
  dynamic environments.
19
19
  DESCRIPTION
20
20
 
21
- s.required_ruby_version = '>= 1.9.3'
21
+ s.required_ruby_version = '>= 2.0.0'
22
22
 
23
23
  s.license = 'Apache-2.0'
24
24
 
25
25
  s.add_dependency 'colored', '1.2'
26
- s.add_dependency 'cri', '~> 2.6.1'
26
+ s.add_dependency 'cri', '~> 2.8'
27
27
 
28
28
  s.add_dependency 'log4r', '1.1.10'
29
29
  s.add_dependency 'multi_json', '~> 1.10'
30
30
 
31
- s.add_dependency 'puppet_forge', '~> 2.3.0'
31
+ s.add_dependency 'puppet_forge', '~> 2.2.8'
32
32
 
33
33
  s.add_dependency 'gettext-setup', '~>0.24'
34
- # These two pins narrow what is allowed by gettext-setup,
35
- # to preserver compatability with Ruby 2.4
36
- s.add_dependency 'fast_gettext', '~> 1.1.0'
37
- s.add_dependency 'gettext', ['>= 3.0.2', '< 3.3.0']
38
34
 
39
35
  s.add_development_dependency 'rspec', '~> 3.1'
40
36
 
41
37
  s.add_development_dependency 'rake'
42
38
 
43
39
  s.add_development_dependency 'yard', '~> 0.9.11'
44
- s.add_development_dependency 'minitar', '~> 0.9.0'
40
+ s.add_development_dependency 'minitar', '~> 0.6.1'
45
41
 
46
42
  s.files = %x[git ls-files].split($/)
47
43
  s.require_path = 'lib'
@@ -37,6 +37,12 @@ sources:
37
37
  # for more information about the Puppet 'environmentpath' setting.
38
38
  #basedir: '/etc/puppetlabs/puppet/environments'
39
39
 
40
+ # The Puppetfile filename in the repo, defaults to 'Puppetfile'. This
41
+ # setting can be used, to allow custom Puppetfile names to allow hybrid
42
+ # use of librarian-puppet (transitive dependency resolution) and r10k
43
+ # (code management on the server).
44
+ #puppetfile_name: 'Puppetfile.r10k'
45
+
40
46
  # One or more sources can be specified; each source is simple another entry
41
47
  # in the sources map.
42
48
  #qa:
@@ -0,0 +1,10 @@
1
+ forge "http://forge.puppetlabs.com"
2
+
3
+ mod "puppetlabs/stdlib", '4.11.0'
4
+ mod "puppetlabs/stdlib", '4.12.0'
5
+ mod "puppetlabs/concat", '2.1.0'
6
+ mod "otheruser/concat", '2.1.0'
7
+
8
+ mod 'apache',
9
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
10
+ :branch => 'docs_experiment'
@@ -0,0 +1 @@
1
+ mod 'branan/eight_hundred', undefined_lookup_function('eight_hundred')
@@ -158,4 +158,50 @@ RSpec.shared_examples "a git working repository" do
158
158
  expect(subject.origin).to eq remote
159
159
  end
160
160
  end
161
+
162
+ describe "checking out ref" do
163
+ before(:each) do
164
+ subject.clone(remote)
165
+ File.open(File.join(subject.path, 'README.markdown'), 'a') { |f| f.write('local modifications!') }
166
+ end
167
+
168
+ context "with force = true" do
169
+ it "should revert changes in managed files" do
170
+ subject.checkout(subject.head, {:force => true})
171
+ expect(File.read(File.join(subject.path, 'README.markdown')).include?('local modifications!')).to eq false
172
+ end
173
+ end
174
+
175
+ context "with force = false" do
176
+ it "should not revert changes in managed files" do
177
+ subject.checkout(subject.head, {:force => false})
178
+ expect(File.read(File.join(subject.path, 'README.markdown')).include?('local modifications!')).to eq true
179
+ end
180
+ end
181
+ end
182
+
183
+ describe "checking if worktree is dirty" do
184
+ before do
185
+ subject.clone(remote)
186
+ end
187
+
188
+ context "with no local changes" do
189
+ it "reports worktree as not dirty" do
190
+ expect(subject.dirty?).to be false
191
+ end
192
+ end
193
+
194
+ context "with local changes" do
195
+ before(:each) do
196
+ File.open(File.join(subject.path, 'README.markdown'), 'a') { |f| f.write('local modifications!') }
197
+ end
198
+
199
+ it "logs and reports worktree as dirty" do
200
+ expect(subject.logger).to receive(:debug).with(/found local modifications in.*README\.markdown/i)
201
+ expect(subject.logger).to receive(:debug1)
202
+
203
+ expect(subject.dirty?).to be true
204
+ end
205
+ end
206
+ end
161
207
  end
@@ -19,10 +19,6 @@ describe R10K::Action::Deploy::Environment do
19
19
  described_class.new({puppetfile: true}, [])
20
20
  end
21
21
 
22
- it "can accept a default_branch_override option" do
23
- described_class.new({:'default-branch-override' => 'default_branch_override_name'}, [])
24
- end
25
-
26
22
  it "can accept a no-force option" do
27
23
  described_class.new({:'no-force' => true}, [])
28
24
  end
@@ -127,63 +123,4 @@ describe R10K::Action::Deploy::Environment do
127
123
  end
128
124
  end
129
125
  end
130
-
131
- describe "write_environment_info!" do
132
-
133
- class Fake_Environment
134
- attr_accessor :path
135
- attr_accessor :puppetfile
136
- attr_accessor :info
137
-
138
- def initialize(path, info)
139
- @path = path
140
- @info = info
141
- @puppetfile = R10K::Puppetfile.new
142
- end
143
- end
144
-
145
- let(:mock_stateful_repo_1) { instance_double("R10K::Git::StatefulRepository", :head => "123456") }
146
- let(:mock_stateful_repo_2) { instance_double("R10K::Git::StatefulRepository", :head => "654321") }
147
- let(:mock_git_module_1) { instance_double("R10K::Module::Git", :name => "my_cool_module", :version => "1.0", :repo => mock_stateful_repo_1) }
148
- let(:mock_git_module_2) { instance_double("R10K::Module::Git", :name => "my_lame_module", :version => "0.0.1", :repo => mock_stateful_repo_2) }
149
- let(:mock_forge_module_1) { double(:name => "their_shiny_module", :version => "2.0.0") }
150
- let(:mock_puppetfile) { instance_double("R10K::Puppetfile", :modules => [mock_git_module_1, mock_git_module_2, mock_forge_module_1]) }
151
-
152
- before(:all) do
153
- @tmp_path = "./tmp-r10k-test-dir/"
154
- Dir.mkdir(@tmp_path) unless File.exists?(@tmp_path)
155
- end
156
-
157
- after(:all) do
158
- File.delete("#{@tmp_path}/.r10k-deploy.json")
159
- Dir.delete(@tmp_path)
160
- end
161
-
162
- it "writes the .r10k-deploy file correctly" do
163
- allow(R10K::Puppetfile).to receive(:new).and_return(mock_puppetfile)
164
- allow(mock_forge_module_1).to receive(:repo).and_raise(NoMethodError)
165
-
166
- fake_env = Fake_Environment.new(@tmp_path, {:name => "my_cool_environment", :signature => "pablo picasso"})
167
- subject.send(:write_environment_info!, fake_env, "2019-01-01 23:23:22 +0000", true)
168
-
169
- file_contents = File.read("#{@tmp_path}/.r10k-deploy.json")
170
- r10k_deploy = JSON.parse(file_contents)
171
-
172
- expect(r10k_deploy['name']).to eq("my_cool_environment")
173
- expect(r10k_deploy['signature']).to eq("pablo picasso")
174
- expect(r10k_deploy['started_at']).to eq("2019-01-01 23:23:22 +0000")
175
- expect(r10k_deploy['deploy_success']).to eq(true)
176
- expect(r10k_deploy['module_deploys'].length).to eq(3)
177
- expect(r10k_deploy['module_deploys'][0]['name']).to eq("my_cool_module")
178
- expect(r10k_deploy['module_deploys'][0]['version']).to eq("1.0")
179
- expect(r10k_deploy['module_deploys'][0]['sha']).to eq("123456")
180
- expect(r10k_deploy['module_deploys'][1]['name']).to eq("my_lame_module")
181
- expect(r10k_deploy['module_deploys'][1]['version']).to eq("0.0.1")
182
- expect(r10k_deploy['module_deploys'][1]['sha']).to eq("654321")
183
- expect(r10k_deploy['module_deploys'][2]['name']).to eq("their_shiny_module")
184
- expect(r10k_deploy['module_deploys'][2]['version']).to eq("2.0.0")
185
- expect(r10k_deploy['module_deploys'][2]['sha']).to eq(nil)
186
-
187
- end
188
- end
189
126
  end
@@ -2,25 +2,40 @@ require 'spec_helper'
2
2
  require 'r10k/action/puppetfile/check'
3
3
 
4
4
  describe R10K::Action::Puppetfile::Check do
5
+ let(:default_opts) { {root: "/some/nonexistent/path"} }
6
+ let(:puppetfile) { instance_double('R10K::Puppetfile', :load! => true) }
5
7
 
6
- subject { described_class.new({root: "/some/nonexistent/path"}, []) }
7
-
8
- let(:puppetfile) { instance_double('R10K::Puppetfile') }
8
+ def checker(opts = {}, argv = [], settings = {})
9
+ opts = default_opts.merge(opts)
10
+ return described_class.new(opts, argv, settings)
11
+ end
9
12
 
10
- before { allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil).and_return(puppetfile) }
13
+ before(:each) do
14
+ allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil).and_return(puppetfile)
15
+ end
11
16
 
12
17
  it_behaves_like "a puppetfile action"
13
18
 
14
19
  it "prints 'Syntax OK' when the Puppetfile syntax could be validated" do
15
- expect(puppetfile).to receive(:load!)
16
20
  expect($stderr).to receive(:puts).with("Syntax OK")
17
- subject.call
21
+
22
+ checker.call
18
23
  end
19
24
 
20
25
  it "prints an error message when validating the Puppetfile syntax raised an error" do
21
- expect(puppetfile).to receive(:load!).and_raise(R10K::Error.new("Boom!"))
22
- expect(R10K::Errors::Formatting).to receive(:format_exception).with(instance_of(R10K::Error), anything).and_return("Formatted error message")
26
+ allow(puppetfile).to receive(:load!).and_raise(R10K::Error.new("Boom!"))
27
+ allow(R10K::Errors::Formatting).to receive(:format_exception).with(instance_of(R10K::Error), anything).and_return("Formatted error message")
28
+
23
29
  expect($stderr).to receive(:puts).with("Formatted error message")
24
- subject.call
30
+
31
+ checker.call
32
+ end
33
+
34
+ it "respects --puppetfile option" do
35
+ allow($stderr).to receive(:puts)
36
+
37
+ expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, "/custom/puppetfile/path").and_return(puppetfile)
38
+
39
+ checker({puppetfile: "/custom/puppetfile/path"}).call
25
40
  end
26
41
  end
@@ -31,32 +31,14 @@ describe R10K::Action::Puppetfile::CriRunner do
31
31
  end
32
32
 
33
33
  describe "for the moduledir" do
34
- before do
35
- allow(cri_runner).to receive(:env).and_return({'PUPPETFILE_DIR' => '/some/nonexistent/modules'})
36
- end
37
-
38
- it "sets the option from the environment when the cli option is not given" do
39
- opts = {}
40
- expect(cri_runner.handle_opts(opts)).to include(:moduledir => '/some/nonexistent/modules')
41
- end
42
-
43
- it "doesn't set the option from the environment when the cli option is given" do
34
+ it "sets the option from the cli option if given" do
44
35
  opts = {:moduledir => '/some/other/nonexistent/modules'}
45
36
  expect(cri_runner.handle_opts(opts)).to include(:moduledir => '/some/other/nonexistent/modules')
46
37
  end
47
38
  end
48
39
 
49
40
  describe "for the puppetfile path" do
50
- before do
51
- allow(cri_runner).to receive(:env).and_return({'PUPPETFILE' => '/some/nonexistent/Puppetfile'})
52
- end
53
-
54
- it "sets the option from the environment when the cli option is not given" do
55
- opts = {}
56
- expect(cri_runner.handle_opts(opts)).to include(:puppetfile => '/some/nonexistent/Puppetfile')
57
- end
58
-
59
- it "doesn't set the option from the environment when the cli option is given" do
41
+ it "sets the option from the cli option if given" do
60
42
  opts = {:puppetfile => '/some/other/nonexistent/modules'}
61
43
  expect(cri_runner.handle_opts(opts)).to include(:puppetfile => '/some/other/nonexistent/modules')
62
44
  end
@@ -2,11 +2,14 @@ require 'spec_helper'
2
2
  require 'r10k/action/puppetfile/install'
3
3
 
4
4
  describe R10K::Action::Puppetfile::Install do
5
-
6
- subject { described_class.new({root: "/some/nonexistent/path"}, []) }
7
-
5
+ let(:default_opts) { {root: "/some/nonexistent/path"} }
8
6
  let(:puppetfile) { R10K::Puppetfile.new('/some/nonexistent/path', nil, nil) }
9
7
 
8
+ def installer(opts = {}, argv = [], settings = {})
9
+ opts = default_opts.merge(opts)
10
+ return described_class.new(opts, argv, settings)
11
+ end
12
+
10
13
  before(:each) do
11
14
  allow(puppetfile).to receive(:load!).and_return(nil)
12
15
  allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil, nil, nil).and_return(puppetfile)
@@ -25,45 +28,42 @@ describe R10K::Action::Puppetfile::Install do
25
28
  end
26
29
 
27
30
  it "syncs each module in the Puppetfile" do
28
- expect(puppetfile).to receive(:load!)
29
31
  modules.each { |m| expect(m).to receive(:sync) }
30
- expect(subject.call).to eq true
32
+
33
+ expect(installer.call).to eq true
31
34
  end
32
35
 
33
36
  it "returns false if a module failed to install" do
34
- expect(puppetfile).to receive(:load!)
35
-
36
37
  modules[0..2].each { |m| expect(m).to receive(:sync) }
37
38
  expect(modules[3]).to receive(:sync).and_raise
38
- expect(subject.call).to eq false
39
+
40
+ expect(installer.call).to eq false
39
41
  end
40
42
  end
41
43
 
42
44
  describe "purging" do
43
45
  before do
44
- allow(puppetfile).to receive(:load!)
45
46
  allow(puppetfile).to receive(:modules).and_return([])
46
47
  end
47
48
 
48
49
  it "purges the moduledir after installation" do
49
50
  expect(puppetfile).to receive(:purge!)
50
- subject.call
51
+
52
+ installer.call
51
53
  end
52
54
  end
53
55
 
54
56
  describe "using custom paths" do
55
- let(:puppetfile) { instance_double("R10K::Puppetfile", load!: nil, accept: nil, purge!: nil) }
56
-
57
57
  it "can use a custom puppetfile path" do
58
- subject = described_class.new({root: "/some/nonexistent/path", puppetfile: "/some/other/path/Puppetfile"}, [])
59
58
  expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, "/some/other/path/Puppetfile", nil, nil).and_return(puppetfile)
60
- subject.call
59
+
60
+ installer({puppetfile: "/some/other/path/Puppetfile"}).call
61
61
  end
62
62
 
63
63
  it "can use a custom moduledir path" do
64
- subject = described_class.new({root: "/some/nonexistent/path", moduledir: "/some/other/path/site-modules"}, [])
65
64
  expect(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", "/some/other/path/site-modules", nil, nil, nil).and_return(puppetfile)
66
- subject.call
65
+
66
+ installer({moduledir: "/some/other/path/site-modules"}).call
67
67
  end
68
68
  end
69
69
 
@@ -2,18 +2,41 @@ require 'spec_helper'
2
2
  require 'r10k/action/puppetfile/purge'
3
3
 
4
4
  describe R10K::Action::Puppetfile::Purge do
5
+ let(:default_opts) { {root: "/some/nonexistent/path"} }
6
+ let(:puppetfile) { instance_double('R10K::Puppetfile', :load! => nil) }
5
7
 
6
- subject { described_class.new({root: "/some/nonexistent/path"}, []) }
7
-
8
- let(:puppetfile) { instance_double('R10K::Puppetfile') }
8
+ def purger(opts = {}, argv = [], settings = {})
9
+ opts = default_opts.merge(opts)
10
+ return described_class.new(opts, argv, settings)
11
+ end
9
12
 
10
- before { allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil).and_return(puppetfile) }
13
+ before(:each) do
14
+ allow(R10K::Puppetfile).to receive(:new).with("/some/nonexistent/path", nil, nil).and_return(puppetfile)
15
+ end
11
16
 
12
17
  it_behaves_like "a puppetfile action"
13
18
 
14
19
  it "purges unmanaged entries in the Puppetfile moduledir" do
15
- allow(puppetfile).to receive(:load!)
16
20
  expect(puppetfile).to receive(:purge!)
17
- subject.call
21
+
22
+ purger.call
23
+ end
24
+
25
+ describe "using custom paths" do
26
+ before(:each) do
27
+ allow(puppetfile).to receive(:purge!)
28
+ end
29
+
30
+ 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)
32
+
33
+ purger({puppetfile: "/some/other/path/Puppetfile"}).call
34
+ end
35
+
36
+ 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)
38
+
39
+ purger({moduledir: "/some/other/path/site-modules"}).call
40
+ end
18
41
  end
19
42
  end
@@ -132,13 +132,15 @@ describe R10K::Forge::ModuleRelease do
132
132
  describe "#cleanup_unpack_path" do
133
133
  it "ignores the unpack_path if it doesn't exist" do
134
134
  expect(unpack_path).to receive(:exist?).and_return false
135
- expect(unpack_path).to_not receive(:rmtree)
135
+ expect(unpack_path).to_not receive(:parent)
136
136
  subject.cleanup_unpack_path
137
137
  end
138
138
 
139
- it "removes the unpack_path if it exists" do
139
+ it "removes the containing directory of unpack_path if it exists" do
140
+ parent = instance_double('Pathname')
141
+ expect(parent).to receive(:rmtree)
140
142
  expect(unpack_path).to receive(:exist?).and_return true
141
- expect(unpack_path).to receive(:rmtree)
143
+ expect(unpack_path).to receive(:parent).and_return(parent)
142
144
  subject.cleanup_unpack_path
143
145
  end
144
146
  end
@@ -146,13 +148,15 @@ describe R10K::Forge::ModuleRelease do
146
148
  describe "#cleanup_download_path" do
147
149
  it "ignores the download_path if it doesn't exist" do
148
150
  expect(download_path).to receive(:exist?).and_return false
149
- expect(download_path).to_not receive(:delete)
151
+ expect(download_path).to_not receive(:parent)
150
152
  subject.cleanup_download_path
151
153
  end
152
154
 
153
- it "removes the download_path if it exists" do
155
+ it "removes the containing directory of download_path if it exists" do
156
+ parent = instance_double('Pathname')
157
+ expect(parent).to receive(:rmtree)
154
158
  expect(download_path).to receive(:exist?).and_return true
155
- expect(download_path).to receive(:delete)
159
+ expect(download_path).to receive(:parent).and_return(parent)
156
160
  subject.cleanup_download_path
157
161
  end
158
162
  end
@@ -21,23 +21,20 @@ describe R10K::Git::StatefulRepository do
21
21
 
22
22
  it "is true if the ref is unresolvable" do
23
23
  expect(cache).to receive(:exist?).and_return true
24
- expect(cache).to receive(:resolve).with('0.9.x')
24
+ expect(cache).to receive(:ref_type).with('0.9.x').and_return(:unknown)
25
25
  expect(subject.sync_cache?(ref)).to eq true
26
26
  end
27
27
 
28
28
  it "is true if the ref is not a tag or commit" do
29
29
  expect(cache).to receive(:exist?).and_return true
30
- expect(cache).to receive(:resolve).with('0.9.x').and_return('93456ec7dc0f6fd3ac193b4df64f6544615dfbc9')
31
30
  expect(cache).to receive(:ref_type).with('0.9.x').and_return(:branch)
32
31
  expect(subject.sync_cache?(ref)).to eq true
33
32
  end
34
33
 
35
34
  it "is false otherwise" do
36
35
  expect(cache).to receive(:exist?).and_return true
37
- expect(cache).to receive(:resolve).with('0.9.x').and_return('93456ec7dc0f6fd3ac193b4df64f6544615dfbc9')
38
36
  expect(cache).to receive(:ref_type).with('0.9.x').and_return(:tag)
39
37
  expect(subject.sync_cache?(ref)).to eq false
40
38
  end
41
-
42
39
  end
43
40
  end