librarian-puppet 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE +20 -0
- data/README.md +0 -0
- data/bin/librarian-puppet +9 -0
- data/lib/librarian/puppet.rb +7 -0
- data/lib/librarian/puppet/cli.rb +30 -0
- data/lib/librarian/puppet/dsl.rb +14 -0
- data/lib/librarian/puppet/environment.rb +18 -0
- data/lib/librarian/puppet/extension.rb +9 -0
- data/lib/librarian/puppet/source.rb +2 -0
- data/lib/librarian/puppet/source/git.rb +12 -0
- data/lib/librarian/puppet/source/local.rb +46 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/templates/Puppetfile +6 -0
- data/librarian-puppet.gemspec +126 -0
- data/vendor/librarian/.rspec +1 -0
- data/vendor/librarian/.travis.yml +6 -0
- data/vendor/librarian/CHANGELOG.md +168 -0
- data/vendor/librarian/Gemfile +4 -0
- data/vendor/librarian/MIT-LICENSE +20 -0
- data/vendor/librarian/README.md +318 -0
- data/vendor/librarian/Rakefile +34 -0
- data/vendor/librarian/bin/librarian-chef +7 -0
- data/vendor/librarian/bin/librarian-mock +7 -0
- data/vendor/librarian/config/cucumber.yaml +1 -0
- data/vendor/librarian/features/chef/cli/init.feature +10 -0
- data/vendor/librarian/features/chef/cli/install.feature +64 -0
- data/vendor/librarian/features/chef/cli/show.feature +65 -0
- data/vendor/librarian/features/chef/cli/version.feature +11 -0
- data/vendor/librarian/features/support/env.rb +9 -0
- data/vendor/librarian/lib/librarian.rb +19 -0
- data/vendor/librarian/lib/librarian/action.rb +5 -0
- data/vendor/librarian/lib/librarian/action/base.rb +22 -0
- data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
- data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
- data/vendor/librarian/lib/librarian/action/install.rb +95 -0
- data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
- data/vendor/librarian/lib/librarian/action/update.rb +78 -0
- data/vendor/librarian/lib/librarian/chef.rb +1 -0
- data/vendor/librarian/lib/librarian/chef/cli.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/chef/environment.rb +19 -0
- data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +47 -0
- data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
- data/vendor/librarian/lib/librarian/chef/source/git.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/local.rb +63 -0
- data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/site.rb +434 -0
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
- data/vendor/librarian/lib/librarian/cli.rb +175 -0
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
- data/vendor/librarian/lib/librarian/dependency.rb +95 -0
- data/vendor/librarian/lib/librarian/dsl.rb +105 -0
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
- data/vendor/librarian/lib/librarian/dsl/target.rb +176 -0
- data/vendor/librarian/lib/librarian/environment.rb +129 -0
- data/vendor/librarian/lib/librarian/error.rb +4 -0
- data/vendor/librarian/lib/librarian/helpers.rb +13 -0
- data/vendor/librarian/lib/librarian/helpers/debug.rb +35 -0
- data/vendor/librarian/lib/librarian/lockfile.rb +33 -0
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +70 -0
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +104 -0
- data/vendor/librarian/lib/librarian/manifest.rb +140 -0
- data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
- data/vendor/librarian/lib/librarian/mock.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
- data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
- data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
- data/vendor/librarian/lib/librarian/resolution.rb +44 -0
- data/vendor/librarian/lib/librarian/resolver.rb +73 -0
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +122 -0
- data/vendor/librarian/lib/librarian/source.rb +2 -0
- data/vendor/librarian/lib/librarian/source/git.rb +150 -0
- data/vendor/librarian/lib/librarian/source/git/repository.rb +213 -0
- data/vendor/librarian/lib/librarian/source/local.rb +51 -0
- data/vendor/librarian/lib/librarian/source/path.rb +74 -0
- data/vendor/librarian/lib/librarian/spec.rb +13 -0
- data/vendor/librarian/lib/librarian/spec_change_set.rb +170 -0
- data/vendor/librarian/lib/librarian/specfile.rb +22 -0
- data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
- data/vendor/librarian/lib/librarian/ui.rb +64 -0
- data/vendor/librarian/lib/librarian/version.rb +3 -0
- data/vendor/librarian/librarian.gemspec +33 -0
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
- data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
- data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
- data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
- data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
- data/vendor/librarian/spec/unit/dependency_spec.rb +30 -0
- data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
- data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
- data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
- data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
- data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
- data/vendor/librarian/spec/unit/manifest_spec.rb +30 -0
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
- data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
- data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
- data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
- metadata +163 -0
@@ -0,0 +1,215 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'json'
|
3
|
+
require 'webmock'
|
4
|
+
|
5
|
+
require 'librarian'
|
6
|
+
require 'librarian/helpers'
|
7
|
+
require 'librarian/action/resolve'
|
8
|
+
require 'librarian/action/install'
|
9
|
+
require 'librarian/chef'
|
10
|
+
|
11
|
+
module Librarian
|
12
|
+
module Chef
|
13
|
+
module Source
|
14
|
+
describe Site do
|
15
|
+
|
16
|
+
include WebMock::API
|
17
|
+
|
18
|
+
let(:project_path) do
|
19
|
+
project_path = Pathname.new(__FILE__).expand_path
|
20
|
+
project_path = project_path.dirname until project_path.join("Rakefile").exist?
|
21
|
+
project_path
|
22
|
+
end
|
23
|
+
let(:tmp_path) { project_path.join("tmp/spec/chef/site-source") }
|
24
|
+
let(:sample_path) { tmp_path.join("sample") }
|
25
|
+
let(:sample_metadata) do
|
26
|
+
Helpers.strip_heredoc(<<-METADATA)
|
27
|
+
version "0.6.5"
|
28
|
+
METADATA
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:api_url) { "http://site.cookbooks.com" }
|
32
|
+
|
33
|
+
let(:sample_index_data) do
|
34
|
+
{
|
35
|
+
"name" => "sample",
|
36
|
+
"versions" => [
|
37
|
+
"#{api_url}/cookbooks/sample/versions/0_6_5"
|
38
|
+
]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
let(:sample_0_6_5_data) do
|
42
|
+
{
|
43
|
+
"version" => "0.6.5",
|
44
|
+
"file" => "#{api_url}/cookbooks/sample/versions/0_6_5/file.tar.gz"
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# depends on repo_path being defined in each context
|
49
|
+
let(:env) { Environment.new(:project_path => repo_path) }
|
50
|
+
|
51
|
+
before :all do
|
52
|
+
sample_path.rmtree if sample_path.exist?
|
53
|
+
sample_path.mkpath
|
54
|
+
sample_path.join("metadata.rb").open("wb") { |f| f.write(sample_metadata) }
|
55
|
+
Dir.chdir(sample_path.dirname) do
|
56
|
+
system "tar --create --gzip --file sample.tar.gz #{sample_path.basename}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
before do
|
61
|
+
stub_request(:get, "#{api_url}/cookbooks/sample").
|
62
|
+
to_return(:body => JSON.dump(sample_index_data))
|
63
|
+
|
64
|
+
stub_request(:get, "#{api_url}/cookbooks/sample/versions/0_6_5").
|
65
|
+
to_return(:body => JSON.dump(sample_0_6_5_data))
|
66
|
+
|
67
|
+
stub_request(:get, "#{api_url}/cookbooks/sample/versions/0_6_5/file.tar.gz").
|
68
|
+
to_return(:body => sample_path.dirname.join("sample.tar.gz").read)
|
69
|
+
end
|
70
|
+
|
71
|
+
after do
|
72
|
+
WebMock.reset!
|
73
|
+
end
|
74
|
+
|
75
|
+
context "a single dependency with a site source" do
|
76
|
+
|
77
|
+
context "resolving" do
|
78
|
+
let(:repo_path) { tmp_path.join("repo/resolve") }
|
79
|
+
before do
|
80
|
+
repo_path.rmtree if repo_path.exist?
|
81
|
+
repo_path.mkpath
|
82
|
+
repo_path.join("cookbooks").mkpath
|
83
|
+
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
84
|
+
#!/usr/bin/env ruby
|
85
|
+
cookbook "sample", :site => #{api_url.inspect}
|
86
|
+
CHEFFILE
|
87
|
+
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
88
|
+
end
|
89
|
+
|
90
|
+
context "the resolve" do
|
91
|
+
it "should not raise an exception" do
|
92
|
+
expect { Action::Resolve.new(env).run }.to_not raise_error
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "the results" do
|
97
|
+
before { Action::Resolve.new(env).run }
|
98
|
+
|
99
|
+
it "should create the lockfile" do
|
100
|
+
repo_path.join("Cheffile.lock").should exist
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should not attempt to install the cookbok" do
|
104
|
+
repo_path.join("cookbooks/sample").should_not exist
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "intalling" do
|
110
|
+
let(:repo_path) { tmp_path.join("repo/install") }
|
111
|
+
before do
|
112
|
+
repo_path.rmtree if repo_path.exist?
|
113
|
+
repo_path.mkpath
|
114
|
+
repo_path.join("cookbooks").mkpath
|
115
|
+
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
116
|
+
#!/usr/bin/env ruby
|
117
|
+
cookbook "sample", :site => #{api_url.inspect}
|
118
|
+
CHEFFILE
|
119
|
+
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
120
|
+
|
121
|
+
Action::Resolve.new(env).run
|
122
|
+
end
|
123
|
+
|
124
|
+
context "the install" do
|
125
|
+
it "should not raise an exception" do
|
126
|
+
expect { Action::Install.new(env).run }.to_not raise_error
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "the results" do
|
131
|
+
before { Action::Install.new(env).run }
|
132
|
+
|
133
|
+
it "should create the lockfile" do
|
134
|
+
repo_path.join("Cheffile.lock").should exist
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should create a directory for the cookbook" do
|
138
|
+
repo_path.join("cookbooks/sample").should exist
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should copy the cookbook files into the cookbook directory" do
|
142
|
+
repo_path.join("cookbooks/sample/metadata.rb").should exist
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "resolving and separately installing" do
|
148
|
+
let(:repo_path) { tmp_path.join("repo/resolve-install") }
|
149
|
+
before do
|
150
|
+
repo_path.rmtree if repo_path.exist?
|
151
|
+
repo_path.mkpath
|
152
|
+
repo_path.join("cookbooks").mkpath
|
153
|
+
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
154
|
+
#!/usr/bin/env ruby
|
155
|
+
cookbook "sample", :site => #{api_url.inspect}
|
156
|
+
CHEFFILE
|
157
|
+
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
158
|
+
|
159
|
+
Action::Resolve.new(env).run
|
160
|
+
repo_path.join("tmp").rmtree if repo_path.join("tmp").exist?
|
161
|
+
end
|
162
|
+
|
163
|
+
context "the install" do
|
164
|
+
it "should not raise an exception" do
|
165
|
+
expect { Action::Install.new(env).run }.to_not raise_error
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "the results" do
|
170
|
+
before { Action::Install.new(env).run }
|
171
|
+
|
172
|
+
it "should create a directory for the cookbook" do
|
173
|
+
repo_path.join("cookbooks/sample").should exist
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should copy the cookbook files into the cookbook directory" do
|
177
|
+
repo_path.join("cookbooks/sample/metadata.rb").should exist
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
context "when the repo path has a space" do
|
185
|
+
|
186
|
+
let(:repo_path) { tmp_path.join("repo/with extra spaces/resolve") }
|
187
|
+
|
188
|
+
before do
|
189
|
+
repo_path.rmtree if repo_path.exist?
|
190
|
+
repo_path.mkpath
|
191
|
+
repo_path.join("cookbooks").mkpath
|
192
|
+
|
193
|
+
cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
|
194
|
+
#!/usr/bin/env ruby
|
195
|
+
cookbook "sample", :site => #{api_url.inspect}
|
196
|
+
CHEFFILE
|
197
|
+
repo_path.join("Cheffile").open("wb") { |f| f.write(cheffile) }
|
198
|
+
end
|
199
|
+
|
200
|
+
after do
|
201
|
+
repo_path.rmtree
|
202
|
+
end
|
203
|
+
|
204
|
+
context "the resolution" do
|
205
|
+
it "should not raise an exception" do
|
206
|
+
expect { Action::Resolve.new(env).run }.to_not raise_error
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "librarian/action/base"
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
describe Action::Base do
|
5
|
+
|
6
|
+
let(:env) { mock }
|
7
|
+
let(:action) { described_class.new(env) }
|
8
|
+
|
9
|
+
subject { action }
|
10
|
+
|
11
|
+
it { should respond_to :environment }
|
12
|
+
|
13
|
+
it "should have the environment that was assigned to it" do
|
14
|
+
action.environment.should be env
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require "librarian/action/clean"
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
describe Action::Clean do
|
5
|
+
|
6
|
+
let(:env) { mock }
|
7
|
+
let(:action) { described_class.new(env) }
|
8
|
+
|
9
|
+
before do
|
10
|
+
action.stub(:debug)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#run" do
|
14
|
+
|
15
|
+
describe "behavior" do
|
16
|
+
|
17
|
+
after do
|
18
|
+
action.run
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "clearing the cache path" do
|
22
|
+
|
23
|
+
before do
|
24
|
+
action.stub(:clean_install_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when the cache path is missing" do
|
28
|
+
before do
|
29
|
+
env.stub_chain(:cache_path, :exist?) { false }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not try to clear the cache path" do
|
33
|
+
env.cache_path.should_receive(:rmtree).never
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when the cache path is present" do
|
38
|
+
before do
|
39
|
+
env.stub_chain(:cache_path, :exist?) { true }
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should try to clear the cache path" do
|
43
|
+
env.cache_path.should_receive(:rmtree).exactly(:once)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "clearing the install path" do
|
50
|
+
|
51
|
+
before do
|
52
|
+
action.stub(:clean_cache_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when the install path is missing" do
|
56
|
+
before do
|
57
|
+
env.stub_chain(:install_path, :exist?) { false }
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should not try to clear the install path" do
|
61
|
+
env.install_path.should_receive(:children).never
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when the install path is present" do
|
66
|
+
before do
|
67
|
+
env.stub_chain(:install_path, :exist?) { true }
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should try to clear the install path" do
|
71
|
+
children = [mock, mock, mock]
|
72
|
+
children.each do |child|
|
73
|
+
child.stub(:file?) { false }
|
74
|
+
end
|
75
|
+
env.stub_chain(:install_path, :children) { children }
|
76
|
+
|
77
|
+
children.each do |child|
|
78
|
+
child.should_receive(:rmtree).exactly(:once)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should only try to clear out directories from the install path, not files" do
|
83
|
+
children = [mock(:file? => false), mock(:file? => true), mock(:file? => true)]
|
84
|
+
env.stub_chain(:install_path, :children) { children }
|
85
|
+
|
86
|
+
children.select(&:file?).each do |child|
|
87
|
+
child.should_receive(:rmtree).never
|
88
|
+
end
|
89
|
+
children.reject(&:file?).each do |child|
|
90
|
+
child.should_receive(:rmtree).exactly(:once)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "tmpdir"
|
2
|
+
|
3
|
+
require "librarian/error"
|
4
|
+
require "librarian/action/ensure"
|
5
|
+
|
6
|
+
module Librarian
|
7
|
+
describe Action::Ensure do
|
8
|
+
|
9
|
+
let(:env) { mock }
|
10
|
+
let(:action) { described_class.new(env) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
env.stub(:specfile_name) { "Specfile" }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#run" do
|
17
|
+
|
18
|
+
context "when the environment does not know its project path" do
|
19
|
+
before { env.stub(:project_path) { nil } }
|
20
|
+
|
21
|
+
it "should raise an error describing that the specfile is mising" do
|
22
|
+
expect { action.run }.to raise_error(Error, "Cannot find Specfile!")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when the environment knows its project path" do
|
27
|
+
before { env.stub(:project_path) { Dir.tmpdir } }
|
28
|
+
|
29
|
+
it "should not raise an error" do
|
30
|
+
expect { action.run }.to_not raise_error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require "librarian/error"
|
2
|
+
require "librarian/action/install"
|
3
|
+
|
4
|
+
module Librarian
|
5
|
+
describe Action::Install do
|
6
|
+
|
7
|
+
let(:env) { mock(:specfile_name => "Specfile", :lockfile_name => "Specfile.lock") }
|
8
|
+
let(:action) { described_class.new(env) }
|
9
|
+
|
10
|
+
describe "#run" do
|
11
|
+
|
12
|
+
describe "behavior" do
|
13
|
+
|
14
|
+
describe "checking preconditions" do
|
15
|
+
|
16
|
+
context "when the specfile is missing" do
|
17
|
+
before do
|
18
|
+
env.stub_chain(:specfile_path, :exist?) { false }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should raise an error explaining that the specfile is missing" do
|
22
|
+
expect { action.run }.to raise_error(Error, "Specfile missing!")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when the specfile is present but the lockfile is missing" do
|
27
|
+
before do
|
28
|
+
env.stub_chain(:specfile_path, :exist?) { true }
|
29
|
+
env.stub_chain(:lockfile_path, :exist?) { false }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should raise an error explaining that the lockfile is missing" do
|
33
|
+
expect { action.run }.to raise_error(Error, "Specfile.lock missing!")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when the specfile and lockfile are present but inconsistent" do
|
38
|
+
before do
|
39
|
+
env.stub_chain(:specfile_path, :exist?) { true }
|
40
|
+
env.stub_chain(:lockfile_path, :exist?) { true }
|
41
|
+
action.stub(:spec_consistent_with_lock?) { false }
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should raise an error explaining the inconsistenty" do
|
45
|
+
expect { action.run }.to raise_error(Error, "Specfile and Specfile.lock are out of sync!")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when the specfile and lockfile are present and consistent" do
|
50
|
+
before do
|
51
|
+
env.stub_chain(:specfile_path, :exist?) { true }
|
52
|
+
env.stub_chain(:lockfile_path, :exist?) { true }
|
53
|
+
action.stub(:spec_consistent_with_lock?) { true }
|
54
|
+
action.stub(:perform_installation)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not raise an error" do
|
58
|
+
expect { action.run }.to_not raise_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "performing the install" do
|
65
|
+
|
66
|
+
def mock_manifest(i)
|
67
|
+
double(:name => "manifest-#{i}")
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:manifests) { 3.times.map{|i| mock_manifest(i)} }
|
71
|
+
let(:sorted_manifests) { 4.times.map{|i| mock_manifest(i + 3)} }
|
72
|
+
let(:install_path) { mock }
|
73
|
+
|
74
|
+
before do
|
75
|
+
env.stub(:install_path) { install_path }
|
76
|
+
action.stub(:check_preconditions)
|
77
|
+
action.stub_chain(:lock, :manifests) { manifests }
|
78
|
+
end
|
79
|
+
|
80
|
+
after do
|
81
|
+
action.run
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should sort and install the manifests" do
|
85
|
+
ManifestSet.should_receive(:sort).with(manifests).exactly(:once).ordered { sorted_manifests }
|
86
|
+
|
87
|
+
install_path.stub(:exist?) { false }
|
88
|
+
install_path.should_receive(:mkpath).exactly(:once).ordered
|
89
|
+
|
90
|
+
sorted_manifests.each do |manifest|
|
91
|
+
manifest.should_receive(:install!).exactly(:once).ordered
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should recreate the install path if it already exists" do
|
96
|
+
action.stub(:sorted_manifests) { sorted_manifests }
|
97
|
+
action.stub(:install_manifests)
|
98
|
+
|
99
|
+
install_path.stub(:exist?) { true }
|
100
|
+
install_path.should_receive(:rmtree)
|
101
|
+
install_path.should_receive(:mkpath)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|