r10k 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.mkd +210 -0
  4. data/CONTRIBUTING.mkd +105 -0
  5. data/Gemfile +2 -6
  6. data/README.mkd +97 -0
  7. data/doc/common-patterns.mkd +44 -0
  8. data/doc/dynamic-environments.mkd +12 -5
  9. data/doc/dynamic-environments/configuration.mkd +16 -1
  10. data/doc/dynamic-environments/{git-environments.markdown → git-environments.mkd} +13 -9
  11. data/doc/dynamic-environments/introduction.mkd +1 -2
  12. data/doc/dynamic-environments/master-configuration.mkd +70 -0
  13. data/doc/dynamic-environments/quickstart.mkd +241 -0
  14. data/doc/dynamic-environments/svn-environments.mkd +45 -0
  15. data/doc/dynamic-environments/usage.mkd +44 -5
  16. data/doc/dynamic-environments/workflow-guide.mkd +247 -0
  17. data/doc/faq.mkd +52 -0
  18. data/doc/puppetfile.mkd +203 -0
  19. data/lib/r10k/action/cri_runner.rb +75 -0
  20. data/lib/r10k/action/deploy.rb +9 -0
  21. data/lib/r10k/action/deploy/display.rb +104 -0
  22. data/lib/r10k/action/deploy/environment.rb +92 -0
  23. data/lib/r10k/action/deploy/module.rb +70 -0
  24. data/lib/r10k/action/puppetfile.rb +10 -0
  25. data/lib/r10k/action/puppetfile/check.rb +41 -0
  26. data/lib/r10k/action/puppetfile/cri_runner.rb +32 -0
  27. data/lib/r10k/action/puppetfile/install.rb +53 -0
  28. data/lib/r10k/action/puppetfile/purge.rb +37 -0
  29. data/lib/r10k/action/runner.rb +36 -0
  30. data/lib/r10k/action/visitor.rb +31 -0
  31. data/lib/r10k/cli/deploy.rb +14 -45
  32. data/lib/r10k/cli/puppetfile.rb +15 -53
  33. data/lib/r10k/deployment.rb +113 -58
  34. data/lib/r10k/deployment/basedir.rb +3 -38
  35. data/lib/r10k/deployment/config.rb +2 -1
  36. data/lib/r10k/deployment/source.rb +2 -0
  37. data/lib/r10k/environment/base.rb +40 -0
  38. data/lib/r10k/environment/git.rb +14 -17
  39. data/lib/r10k/environment/svn.rb +31 -15
  40. data/lib/r10k/errors.rb +33 -22
  41. data/lib/r10k/errors/formatting.rb +28 -0
  42. data/lib/r10k/execution.rb +2 -0
  43. data/lib/r10k/git/cache.rb +1 -6
  44. data/lib/r10k/git/errors.rb +1 -2
  45. data/lib/r10k/git/ref.rb +1 -1
  46. data/lib/r10k/module.rb +1 -1
  47. data/lib/r10k/module/base.rb +94 -2
  48. data/lib/r10k/module/forge.rb +33 -30
  49. data/lib/r10k/module/git.rb +13 -9
  50. data/lib/r10k/module/svn.rb +41 -28
  51. data/lib/r10k/puppetfile.rb +17 -1
  52. data/lib/r10k/semver.rb +2 -0
  53. data/lib/r10k/source/base.rb +8 -0
  54. data/lib/r10k/source/git.rb +1 -1
  55. data/lib/r10k/source/svn.rb +23 -5
  56. data/lib/r10k/svn/remote.rb +23 -3
  57. data/lib/r10k/svn/working_dir.rb +60 -9
  58. data/lib/r10k/task.rb +1 -0
  59. data/lib/r10k/task/deployment.rb +9 -1
  60. data/lib/r10k/task/environment.rb +2 -0
  61. data/lib/r10k/task/module.rb +1 -0
  62. data/lib/r10k/task/puppetfile.rb +3 -0
  63. data/lib/r10k/task_runner.rb +1 -0
  64. data/lib/r10k/util/attempt.rb +84 -0
  65. data/lib/r10k/util/basedir.rb +65 -0
  66. data/lib/r10k/util/purgeable.rb +55 -45
  67. data/lib/r10k/util/setopts.rb +53 -0
  68. data/lib/r10k/util/subprocess.rb +6 -30
  69. data/lib/r10k/util/subprocess/posix/runner.rb +29 -2
  70. data/lib/r10k/util/subprocess/result.rb +17 -4
  71. data/lib/r10k/util/subprocess/subprocess_error.rb +24 -0
  72. data/lib/r10k/version.rb +1 -1
  73. data/r10k.gemspec +7 -29
  74. data/spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile +1 -0
  75. data/spec/fixtures/unit/puppetfile/load-error/Puppetfile +1 -0
  76. data/spec/matchers/exit_with.rb +28 -0
  77. data/spec/r10k-mocks.rb +3 -0
  78. data/spec/r10k-mocks/mock_config.rb +28 -0
  79. data/spec/r10k-mocks/mock_env.rb +7 -0
  80. data/spec/r10k-mocks/mock_source.rb +10 -0
  81. data/spec/shared-examples/git-ref.rb +7 -7
  82. data/spec/spec_helper.rb +17 -5
  83. data/spec/unit/action/cri_runner_spec.rb +76 -0
  84. data/spec/unit/action/puppetfile/cri_action_spec.rb +65 -0
  85. data/spec/unit/action/runner_spec.rb +64 -0
  86. data/spec/unit/action/visitor_spec.rb +39 -0
  87. data/spec/unit/deployment_spec.rb +142 -0
  88. data/spec/unit/environment/base_spec.rb +38 -0
  89. data/spec/unit/environment/git_spec.rb +40 -10
  90. data/spec/unit/environment/svn_spec.rb +41 -4
  91. data/spec/unit/errors/formatting_spec.rb +84 -0
  92. data/spec/unit/git/alternates_spec.rb +1 -1
  93. data/spec/unit/git/head_spec.rb +1 -1
  94. data/spec/unit/git/ref_spec.rb +1 -1
  95. data/spec/unit/git/working_dir_spec.rb +1 -1
  96. data/spec/unit/module/base_spec.rb +72 -0
  97. data/spec/unit/module/forge_spec.rb +49 -8
  98. data/spec/unit/module/git_spec.rb +78 -0
  99. data/spec/unit/module/svn_spec.rb +40 -4
  100. data/spec/unit/module_spec.rb +3 -3
  101. data/spec/unit/puppetfile_spec.rb +84 -0
  102. data/spec/unit/settings/container_spec.rb +1 -1
  103. data/spec/unit/source/base_spec.rb +31 -0
  104. data/spec/unit/source/git_spec.rb +7 -7
  105. data/spec/unit/source/svn_spec.rb +1 -1
  106. data/spec/unit/svn/working_dir_spec.rb +56 -0
  107. data/spec/unit/util/attempt_spec.rb +82 -0
  108. data/spec/unit/util/setopts_spec.rb +59 -0
  109. data/spec/unit/util/subprocess/result_spec.rb +36 -0
  110. data/spec/unit/util/subprocess/subprocess_error_spec.rb +26 -0
  111. data/spec/unit/util/subprocess_spec.rb +2 -7
  112. metadata +83 -100
  113. data/.nodeset.yml +0 -7
  114. data/.rspec +0 -1
  115. data/README.markdown +0 -276
  116. data/Rakefile +0 -1
  117. data/doc/puppetfile.markdown +0 -87
  118. data/spec/rspec-system-r10k/puppetfile.rb +0 -24
  119. data/spec/rspec-system-r10k/tmpdir.rb +0 -32
  120. data/spec/system-provisioning/el.rb +0 -38
  121. data/spec/system/module/forge/install_spec.rb +0 -51
  122. data/spec/system/module/git/install_spec.rb +0 -117
  123. data/spec/system/module/svn/install_spec.rb +0 -51
  124. data/spec/system/module/svn/update_spec.rb +0 -38
  125. data/spec/system/spec_helper.rb +0 -60
  126. data/spec/system/system-helpers.rb +0 -4
  127. data/spec/system/version_spec.rb +0 -7
@@ -35,17 +35,15 @@ describe R10K::Environment::SVN do
35
35
  end
36
36
 
37
37
  describe "synchronizing the environment" do
38
- it "updates all modules when creating a new environment" do
38
+ it "checks out the working directory when creating a new environment" do
39
39
  allow(working_dir).to receive(:is_svn?).and_return(false)
40
40
  expect(working_dir).to receive(:checkout)
41
- expect(subject).to receive(:sync_modules)
42
41
  subject.sync
43
42
  end
44
43
 
45
- it "does not update all modules when updating an existing environment" do
44
+ it "updates the working directory when updating an existing environment" do
46
45
  allow(working_dir).to receive(:is_svn?).and_return(true)
47
46
  expect(working_dir).to receive(:update)
48
- expect(subject).to_not receive(:sync_modules)
49
47
  subject.sync
50
48
  end
51
49
  end
@@ -73,4 +71,43 @@ describe R10K::Environment::SVN do
73
71
  expect(subject.modules).to eq([:modules])
74
72
  end
75
73
  end
74
+
75
+ describe "determining the status" do
76
+ it "is absent if the working directory is absent" do
77
+ expect(subject.path).to receive(:exist?).and_return(false)
78
+ expect(subject.status).to eq :absent
79
+ end
80
+
81
+ it "is mismatched if the working directory is not an SVN repo" do
82
+ expect(subject.path).to receive(:exist?).and_return(true)
83
+ expect(working_dir).to receive(:is_svn?).and_return(false)
84
+ expect(subject.status).to eq :mismatched
85
+ end
86
+
87
+ it "is mismatched if the working directory remote doesn't match the expected remote" do
88
+ expect(subject.path).to receive(:exist?).and_return(true)
89
+ expect(working_dir).to receive(:is_svn?).and_return(true)
90
+ expect(working_dir).to receive(:url).and_return 'https://svn-server.site/another-svn-repo/trunk'
91
+ expect(subject.status).to eq :mismatched
92
+ end
93
+
94
+ it "is outdated when the the working directory has not synced" do
95
+ expect(subject.path).to receive(:exist?).and_return(true)
96
+ expect(working_dir).to receive(:is_svn?).and_return(true)
97
+ expect(working_dir).to receive(:url).and_return 'https://svn-server.site/svn-repo/trunk'
98
+ expect(subject.status).to eq :outdated
99
+ end
100
+
101
+ it "is insync when the working directory has been synced" do
102
+ expect(subject.path).to receive(:exist?).and_return(true)
103
+ expect(working_dir).to receive(:is_svn?).twice.and_return(true)
104
+ expect(working_dir).to receive(:url).and_return 'https://svn-server.site/svn-repo/trunk'
105
+
106
+ expect(working_dir).to receive(:update)
107
+
108
+ subject.sync
109
+
110
+ expect(subject.status).to eq :insync
111
+ end
112
+ end
76
113
  end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+ require 'r10k/errors/formatting'
3
+
4
+ describe R10K::Errors::Formatting do
5
+
6
+ describe "without a nested exception" do
7
+ let(:exc) do
8
+ ArgumentError.new("ArgumentError message").tap do |a|
9
+ a.set_backtrace(%w[/backtrace/line:1 /backtrace/line:2])
10
+ end
11
+ end
12
+
13
+ describe "and without a backtrace" do
14
+ subject do
15
+ described_class.format_exception(exc, false)
16
+ end
17
+
18
+ it "formats the exception with the message" do
19
+ expect(subject).to eq("ArgumentError message")
20
+ end
21
+ end
22
+
23
+ describe "and with a backtrace" do
24
+ subject do
25
+ described_class.format_exception(exc, true)
26
+ end
27
+
28
+ it "formats the exception with the message and backtrace" do
29
+ expect(subject).to eq([
30
+ "ArgumentError message",
31
+ "/backtrace/line:1",
32
+ "/backtrace/line:2",
33
+ ].join("\n"))
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "with a nested exception" do
39
+
40
+ let(:nestee) do
41
+ ArgumentError.new("ArgumentError message").tap do |a|
42
+ a.set_backtrace(%w[/backtrace/line:1 /backtrace/line:2])
43
+ end
44
+ end
45
+
46
+ let(:exc) do
47
+ R10K::Error.wrap(nestee, "R10K::Error message").tap do |r|
48
+ r.set_backtrace(%w[/another/backtrace/line:1 /another/backtrace/line:2])
49
+ end
50
+ end
51
+
52
+ describe "and without a backtrace" do
53
+ subject do
54
+ described_class.format_exception(exc, false)
55
+ end
56
+
57
+ it "formats the exception with the message and original message" do
58
+ expect(subject).to eq([
59
+ "R10K::Error message",
60
+ "Original exception:",
61
+ "ArgumentError message"
62
+ ].join("\n"))
63
+ end
64
+ end
65
+
66
+ describe "and with a backtrace" do
67
+ subject do
68
+ described_class.format_exception(exc, true)
69
+ end
70
+
71
+ it "formats the exception with the message, backtrace, original message, and original backtrace" do
72
+ expect(subject).to eq([
73
+ "R10K::Error message",
74
+ "/another/backtrace/line:1",
75
+ "/another/backtrace/line:2",
76
+ "Original exception:",
77
+ "ArgumentError message",
78
+ "/backtrace/line:1",
79
+ "/backtrace/line:2",
80
+ ].join("\n"))
81
+ end
82
+ end
83
+ end
84
+ end
@@ -61,7 +61,7 @@ describe R10K::Git::Alternates do
61
61
 
62
62
  before do
63
63
  expect(subject.file).to receive(:open).with('w').and_yield(io)
64
- subject.file.stub_chain(:parent, :directory?).and_return true
64
+ expect(subject.file).to receive_message_chain(:parent, :directory?).and_return true
65
65
  end
66
66
 
67
67
 
@@ -14,7 +14,7 @@ describe R10K::Git::Head do
14
14
 
15
15
  describe "determining if the head needs to be fetched" do
16
16
  it "is always true" do
17
- expect(subject.fetch?).to be_true
17
+ expect(subject.fetch?).to be_truthy
18
18
  end
19
19
  end
20
20
 
@@ -16,7 +16,7 @@ describe R10K::Git::Ref do
16
16
 
17
17
  it "raises an error if the SHA1 could not be resolved" do
18
18
  subject.repository = repo
19
- expect(repo).to receive(:rev_parse).with(ref).and_raise(R10K::Git::UnresolvableRefError)
19
+ expect(repo).to receive(:rev_parse).with(ref).and_raise(R10K::Git::UnresolvableRefError, "Couldn't resolve")
20
20
 
21
21
  expect {
22
22
  subject.sha1
@@ -7,7 +7,7 @@ describe R10K::Git::WorkingDir do
7
7
  describe "initializing" do
8
8
  it "generates a new cache for the remote" do
9
9
  wd = described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/some/nonexistent/dir')
10
- wd.cache.should be_kind_of R10K::Git::Cache
10
+ expect(wd.cache).to be_kind_of(R10K::Git::Cache)
11
11
  end
12
12
 
13
13
  it "uses the provided ref as the dirname when no dirname is given" do
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'r10k/module/base'
3
+
4
+ describe R10K::Module::Base do
5
+ describe "parsing the title" do
6
+ it "parses titles with no owner" do
7
+ m = described_class.new('eight_hundred', '/moduledir', [])
8
+ expect(m.name).to eq 'eight_hundred'
9
+ expect(m.owner).to be_nil
10
+ end
11
+
12
+ it "parses forward slash separated titles" do
13
+ m = described_class.new('branan/eight_hundred', '/moduledir', [])
14
+ expect(m.name).to eq 'eight_hundred'
15
+ expect(m.owner).to eq 'branan'
16
+ end
17
+
18
+ it "parses hyphen separated titles" do
19
+ m = described_class.new('branan-eight_hundred', '/moduledir', [])
20
+ expect(m.name).to eq 'eight_hundred'
21
+ expect(m.owner).to eq 'branan'
22
+ end
23
+
24
+ it "raises an error when the title is not correctly formatted" do
25
+ expect {
26
+ described_class.new('branan!eight_hundred', '/moduledir', [])
27
+ }.to raise_error(ArgumentError, "Module names must match either 'modulename' or 'owner/modulename'")
28
+ end
29
+ end
30
+
31
+ describe "path variables" do
32
+ it "uses the module name as the name" do
33
+ m = described_class.new('eight_hundred', '/moduledir', [])
34
+ expect(m.dirname).to eq '/moduledir'
35
+ expect(m.path).to eq(Pathname.new('/moduledir/eight_hundred'))
36
+ end
37
+
38
+ it "does not include the owner in the path" do
39
+ m = described_class.new('branan/eight_hundred', '/moduledir', [])
40
+ expect(m.dirname).to eq '/moduledir'
41
+ expect(m.path).to eq(Pathname.new('/moduledir/eight_hundred'))
42
+ end
43
+ end
44
+
45
+ describe "with alternate variable names" do
46
+ subject do
47
+ described_class.new('branan/eight_hundred', '/moduledir', [])
48
+ end
49
+
50
+ it "aliases full_name to title" do
51
+ expect(subject.full_name).to eq 'branan/eight_hundred'
52
+ end
53
+
54
+ it "aliases author to owner" do
55
+ expect(subject.author).to eq 'branan'
56
+ end
57
+
58
+ it "aliases basedir to dirname" do
59
+ expect(subject.basedir).to eq '/moduledir'
60
+ end
61
+ end
62
+
63
+ describe "accepting a visitor" do
64
+ subject { described_class.new('branan/eight_hundred', '/moduledir', []) }
65
+
66
+ it "passes itself to the visitor" do
67
+ visitor = spy('visitor')
68
+ expect(visitor).to receive(:visit).with(:module, subject)
69
+ subject.accept(visitor)
70
+ end
71
+ end
72
+ end
@@ -4,7 +4,6 @@ require 'spec_helper'
4
4
 
5
5
  describe R10K::Module::Forge do
6
6
 
7
- include_context 'stub logging'
8
7
  include_context 'fail on execution'
9
8
 
10
9
  let(:fixture_modulepath) { File.expand_path('spec/fixtures/module/forge', PROJECT_ROOT) }
@@ -15,8 +14,12 @@ describe R10K::Module::Forge do
15
14
  expect(described_class).to be_implement('branan/eight_hundred', '8.0.0')
16
15
  end
17
16
 
18
- it "should fail with an invalid full name" do
19
- expect(described_class).to_not be_implement('branan-eight_hundred', '8.0.0')
17
+ it "should implement 'branan-eight_hundred', '8.0.0'" do
18
+ expect(described_class).to be_implement('branan/eight_hundred', '8.0.0')
19
+ end
20
+
21
+ it "should fail with an invalid title" do
22
+ expect(described_class).to_not be_implement('branan!eight_hundred', '8.0.0')
20
23
  end
21
24
 
22
25
  it "should fail with an invalid version" do
@@ -27,11 +30,49 @@ describe R10K::Module::Forge do
27
30
  describe "setting attributes" do
28
31
  subject { described_class.new('branan/eight_hundred', '/moduledir', '8.0.0') }
29
32
 
30
- its(:name) { should eq 'eight_hundred' }
31
- its(:author) { should eq 'branan' }
32
- its(:full_name) { should eq 'branan/eight_hundred' }
33
- its(:basedir) { should eq '/moduledir' }
34
- its(:full_path) { should eq '/moduledir/eight_hundred' }
33
+ it "sets the name" do
34
+ expect(subject.name).to eq 'eight_hundred'
35
+ end
36
+
37
+ it "sets the author" do
38
+ expect(subject.author).to eq 'branan'
39
+ end
40
+
41
+ it "sets the dirname" do
42
+ expect(subject.dirname).to eq '/moduledir'
43
+ end
44
+
45
+ it "sets the title" do
46
+ expect(subject.title).to eq 'branan/eight_hundred'
47
+ end
48
+ end
49
+
50
+ describe "fetching the current version" do
51
+ subject { described_class.new('branan/eight_hundred', '/moduledir', '8.0.0') }
52
+
53
+ it "reads the metadata before returning the version from the metadata" do
54
+ metadata = subject.metadata
55
+ expect(metadata).to receive(:read)
56
+ expect(metadata).to receive(:version).and_return(R10K::SemVer.new('1.2.3'))
57
+ expect(subject.current_version).to eq(R10K::SemVer.new('1.2.3'))
58
+ end
59
+ end
60
+
61
+ describe "properties" do
62
+ subject { described_class.new('branan/eight_hundred', '/moduledir', '8.0.0') }
63
+
64
+ it "sets the module type to :forge" do
65
+ expect(subject.properties).to include(:type => :forge)
66
+ end
67
+
68
+ it "sets the expected version" do
69
+ expect(subject.properties).to include(:expected => R10K::SemVer.new('8.0.0'))
70
+ end
71
+
72
+ it "sets the actual version" do
73
+ expect(subject).to receive(:current_version).and_return(R10K::SemVer.new('0.8.0'))
74
+ expect(subject.properties).to include(:actual => R10K::SemVer.new('0.8.0'))
75
+ end
35
76
  end
36
77
 
37
78
  describe "when syncing" do
@@ -3,6 +3,84 @@ require 'r10k/module/git'
3
3
 
4
4
  describe R10K::Module::Git do
5
5
 
6
+ describe "setting the owner and name" do
7
+ describe "with a title of 'branan/eight_hundred'" do
8
+ subject do
9
+ described_class.new(
10
+ 'branan/eight_hundred',
11
+ '/moduledir',
12
+ {
13
+ :git => 'git://git-server.site/branan/puppet-eight_hundred',
14
+ }
15
+ )
16
+ end
17
+
18
+ it "sets the owner to 'branan'" do
19
+ expect(subject.owner).to eq 'branan'
20
+ end
21
+
22
+ it "sets the name to 'eight_hundred'" do
23
+ expect(subject.name).to eq 'eight_hundred'
24
+ end
25
+
26
+ it "sets the path to '/moduledir/eight_hundred'" do
27
+ expect(subject.path).to eq(Pathname.new('/moduledir/eight_hundred'))
28
+ end
29
+ end
30
+
31
+ describe "with a title of 'modulename'" do
32
+ subject do
33
+ described_class.new(
34
+ 'eight_hundred',
35
+ '/moduledir',
36
+ {
37
+ :git => 'git://git-server.site/branan/puppet-eight_hundred',
38
+ }
39
+ )
40
+ end
41
+
42
+ it "sets the owner to nil" do
43
+ expect(subject.owner).to be_nil
44
+ end
45
+
46
+ it "sets the name to 'eight_hundred'" do
47
+ expect(subject.name).to eq 'eight_hundred'
48
+ end
49
+
50
+ it "sets the path to '/moduledir/eight_hundred'" do
51
+ expect(subject.path).to eq(Pathname.new('/moduledir/eight_hundred'))
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "properties" do
57
+ subject do
58
+ described_class.new('boolean', '/moduledir', {:git => 'git://github.com/adrienthebo/puppet-boolean'})
59
+ end
60
+
61
+ it "sets the module type to :git" do
62
+ expect(subject.properties).to include(:type => :git)
63
+ end
64
+
65
+ it "sets the expected version" do
66
+ expect(subject.properties).to include(:expected => instance_of(R10K::Git::Ref))
67
+ end
68
+
69
+ it "sets the actual version to the revision when the revision is available" do
70
+ head = double('head')
71
+ expect(subject.working_dir).to receive(:current).and_return(head)
72
+ expect(head).to receive(:sha1).and_return('35d3517e67ceeb4b485b56d4a14d38fb95516c92')
73
+ expect(subject.properties).to include(:actual => '35d3517e67ceeb4b485b56d4a14d38fb95516c92')
74
+ end
75
+
76
+ it "sets the actual version (unresolvable) when the revision is unavailable" do
77
+ head = double('head')
78
+ expect(subject.working_dir).to receive(:current).and_return(head)
79
+ expect(head).to receive(:sha1).and_raise(ArgumentError)
80
+ expect(subject.properties).to include(:actual => '(unresolvable)')
81
+ end
82
+ end
83
+
6
84
  describe "determining the status" do
7
85
  subject do
8
86
  described_class.new(
@@ -13,6 +13,25 @@ describe R10K::Module::SVN do
13
13
  end
14
14
  end
15
15
 
16
+ describe "path variables" do
17
+ it "uses the module name as the name" do
18
+ svn = described_class.new('foo', '/moduledir', :rev => 'r10')
19
+ expect(svn.name).to eq 'foo'
20
+ expect(svn.owner).to be_nil
21
+ expect(svn.dirname).to eq '/moduledir'
22
+ expect(svn.path).to eq Pathname.new('/moduledir/foo')
23
+ end
24
+
25
+ it "does not include the owner in the path" do
26
+ svn = described_class.new('bar/foo', '/moduledir', :rev => 'r10')
27
+ expect(svn.name).to eq 'foo'
28
+ expect(svn.owner).to eq 'bar'
29
+ expect(svn.dirname).to eq '/moduledir'
30
+ expect(svn.path).to eq Pathname.new('/moduledir/foo')
31
+ end
32
+ end
33
+
34
+
16
35
  describe "instantiating based on Puppetfile configuration" do
17
36
  it "can specify a revision with the :rev key" do
18
37
  svn = described_class.new('foo', '/moduledir', :rev => 'r10')
@@ -23,10 +42,27 @@ describe R10K::Module::SVN do
23
42
  svn = described_class.new('foo', '/moduledir', :revision => 'r10')
24
43
  expect(svn.expected_revision).to eq 'r10'
25
44
  end
45
+ end
46
+
47
+ describe "properties" do
48
+ subject { described_class.new('foo', '/moduledir', :svn => 'https://github.com/adrienthebo/r10k-fixture-repo', :rev => 123) }
49
+
50
+ it "sets the module type to :svn" do
51
+ expect(subject.properties).to include(:type => :svn)
52
+ end
53
+
54
+ it "sets the expected version" do
55
+ expect(subject.properties).to include(:expected => 123)
56
+ end
57
+
58
+ it "sets the actual version to the revision when the revision is available" do
59
+ expect(subject.working_dir).to receive(:revision).and_return(12)
60
+ expect(subject.properties).to include(:actual => 12)
61
+ end
26
62
 
27
- it "can specify a path within the SVN repo" do
28
- svn = described_class.new('foo', '/moduledir', :svn_path => 'branches/something/foo')
29
- expect(svn.svn_path).to eq 'branches/something/foo'
63
+ it "sets the actual version (unresolvable) when the revision is unavailable" do
64
+ expect(subject.working_dir).to receive(:revision).and_raise(ArgumentError)
65
+ expect(subject.properties).to include(:actual => "(unresolvable)")
30
66
  end
31
67
  end
32
68
 
@@ -114,7 +150,7 @@ describe R10K::Module::SVN do
114
150
  end
115
151
 
116
152
  it "removes the existing directory" do
117
- expect(subject.full_path).to receive(:rmtree)
153
+ expect(subject.path).to receive(:rmtree)
118
154
  allow(subject).to receive(:install)
119
155
 
120
156
  subject.sync