librarian-puppet-lmco 0.9.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.md +187 -0
- data/bin/librarian-puppet +9 -0
- data/lib/librarian/puppet.rb +22 -0
- data/lib/librarian/puppet/cli.rb +85 -0
- data/lib/librarian/puppet/dsl.rb +16 -0
- data/lib/librarian/puppet/environment.rb +54 -0
- data/lib/librarian/puppet/extension.rb +47 -0
- data/lib/librarian/puppet/lockfile/parser.rb +53 -0
- data/lib/librarian/puppet/source.rb +4 -0
- data/lib/librarian/puppet/source/forge.rb +348 -0
- data/lib/librarian/puppet/source/git.rb +121 -0
- data/lib/librarian/puppet/source/githubtarball.rb +249 -0
- data/lib/librarian/puppet/source/local.rb +57 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/templates/Puppetfile +10 -0
- data/lib/librarian/puppet/version.rb +5 -0
- data/vendor/librarian/CHANGELOG.md +224 -0
- data/vendor/librarian/Gemfile +6 -0
- data/vendor/librarian/MIT-LICENSE +20 -0
- data/vendor/librarian/README.md +401 -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 +11 -0
- data/vendor/librarian/features/chef/cli/install.feature +64 -0
- data/vendor/librarian/features/chef/cli/show.feature +77 -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 +11 -0
- data/vendor/librarian/lib/librarian/action.rb +5 -0
- data/vendor/librarian/lib/librarian/action/base.rb +24 -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/persist_resolution_mixin.rb +51 -0
- data/vendor/librarian/lib/librarian/action/resolve.rb +46 -0
- data/vendor/librarian/lib/librarian/action/update.rb +44 -0
- data/vendor/librarian/lib/librarian/chef.rb +1 -0
- data/vendor/librarian/lib/librarian/chef/cli.rb +47 -0
- data/vendor/librarian/lib/librarian/chef/dsl.rb +16 -0
- data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +46 -0
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
- data/vendor/librarian/lib/librarian/chef/source.rb +4 -0
- data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
- data/vendor/librarian/lib/librarian/chef/source/github.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
- data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/site.rb +442 -0
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
- data/vendor/librarian/lib/librarian/cli.rb +223 -0
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +93 -0
- data/vendor/librarian/lib/librarian/config.rb +7 -0
- data/vendor/librarian/lib/librarian/config/database.rb +205 -0
- data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
- data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
- data/vendor/librarian/lib/librarian/config/source.rb +149 -0
- data/vendor/librarian/lib/librarian/dependency.rb +147 -0
- data/vendor/librarian/lib/librarian/dsl.rb +108 -0
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +46 -0
- data/vendor/librarian/lib/librarian/dsl/target.rb +171 -0
- data/vendor/librarian/lib/librarian/environment.rb +182 -0
- data/vendor/librarian/lib/librarian/error.rb +4 -0
- data/vendor/librarian/lib/librarian/helpers.rb +13 -0
- data/vendor/librarian/lib/librarian/linter/source_linter.rb +55 -0
- data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +123 -0
- data/vendor/librarian/lib/librarian/logger.rb +46 -0
- data/vendor/librarian/lib/librarian/manifest.rb +140 -0
- data/vendor/librarian/lib/librarian/manifest_set.rb +151 -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 +80 -0
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
- data/vendor/librarian/lib/librarian/resolution.rb +46 -0
- data/vendor/librarian/lib/librarian/resolver.rb +81 -0
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +223 -0
- data/vendor/librarian/lib/librarian/source.rb +2 -0
- data/vendor/librarian/lib/librarian/source/basic_api.rb +45 -0
- data/vendor/librarian/lib/librarian/source/git.rb +134 -0
- data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
- data/vendor/librarian/lib/librarian/source/local.rb +54 -0
- data/vendor/librarian/lib/librarian/source/path.rb +56 -0
- data/vendor/librarian/lib/librarian/spec.rb +13 -0
- data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
- data/vendor/librarian/lib/librarian/specfile.rb +17 -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 +35 -0
- data/vendor/librarian/spec/functional/chef/cli_spec.rb +194 -0
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +266 -0
- data/vendor/librarian/spec/functional/source/git/repository_spec.rb +150 -0
- data/vendor/librarian/spec/integration/chef/source/git_spec.rb +441 -0
- data/vendor/librarian/spec/integration/chef/source/site_spec.rb +217 -0
- data/vendor/librarian/spec/support/cli_macro.rb +114 -0
- data/vendor/librarian/spec/support/method_patch_macro.rb +30 -0
- data/vendor/librarian/spec/support/with_env_macro.rb +20 -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/config/database_spec.rb +327 -0
- data/vendor/librarian/spec/unit/dependency_spec.rb +212 -0
- data/vendor/librarian/spec/unit/dsl_spec.rb +173 -0
- data/vendor/librarian/spec/unit/environment_spec.rb +173 -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 +36 -0
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
- data/vendor/librarian/spec/unit/resolver_spec.rb +233 -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 +220 -0
@@ -0,0 +1,162 @@
|
|
1
|
+
require "librarian/helpers"
|
2
|
+
require "librarian/lockfile/parser"
|
3
|
+
require "librarian/mock"
|
4
|
+
|
5
|
+
module Librarian
|
6
|
+
describe Lockfile::Parser do
|
7
|
+
|
8
|
+
let(:env) { Mock::Environment.new }
|
9
|
+
let(:parser) { described_class.new(env) }
|
10
|
+
let(:resolution) { parser.parse(lockfile) }
|
11
|
+
|
12
|
+
context "a mock lockfile with one source and no dependencies" do
|
13
|
+
let(:lockfile) do
|
14
|
+
Helpers.strip_heredoc <<-LOCKFILE
|
15
|
+
MOCK
|
16
|
+
remote: source-a
|
17
|
+
specs:
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
|
21
|
+
LOCKFILE
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should give an empty list of dependencies" do
|
25
|
+
resolution.dependencies.should be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should give an empty list of manifests" do
|
29
|
+
resolution.manifests.should be_empty
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "a mock lockfile with one source and one dependency" do
|
34
|
+
let(:lockfile) do
|
35
|
+
Helpers.strip_heredoc <<-LOCKFILE
|
36
|
+
MOCK
|
37
|
+
remote: source-a
|
38
|
+
specs:
|
39
|
+
jelly (1.3.5)
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
jelly (!= 1.2.6, ~> 1.1)
|
43
|
+
|
44
|
+
LOCKFILE
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should give a list of one dependency" do
|
48
|
+
resolution.should have(1).dependencies
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should give a dependency with the expected name" do
|
52
|
+
dependency = resolution.dependencies.first
|
53
|
+
|
54
|
+
dependency.name.should == "jelly"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should give a dependency with the expected requirement" do
|
58
|
+
dependency = resolution.dependencies.first
|
59
|
+
|
60
|
+
# Note: it must be this order because this order is lexicographically sorted.
|
61
|
+
dependency.requirement.to_s.should == "!= 1.2.6, ~> 1.1"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should give a dependency wth the expected source" do
|
65
|
+
dependency = resolution.dependencies.first
|
66
|
+
source = dependency.source
|
67
|
+
|
68
|
+
source.name.should == "source-a"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should give a list of one manifest" do
|
72
|
+
resolution.should have(1).manifests
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should give a manifest with the expected name" do
|
76
|
+
manifest = resolution.manifests.first
|
77
|
+
|
78
|
+
manifest.name.should == "jelly"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should give a manifest with the expected version" do
|
82
|
+
manifest = resolution.manifests.first
|
83
|
+
|
84
|
+
manifest.version.to_s.should == "1.3.5"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should give a manifest with no dependencies" do
|
88
|
+
manifest = resolution.manifests.first
|
89
|
+
|
90
|
+
manifest.dependencies.should be_empty
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should give a manifest with the expected source" do
|
94
|
+
manifest = resolution.manifests.first
|
95
|
+
source = manifest.source
|
96
|
+
|
97
|
+
source.name.should == "source-a"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should give the dependency and the manifest the same source instance" do
|
101
|
+
dependency = resolution.dependencies.first
|
102
|
+
manifest = resolution.manifests.first
|
103
|
+
|
104
|
+
dependency_source = dependency.source
|
105
|
+
manifest_source = manifest.source
|
106
|
+
|
107
|
+
manifest_source.should be dependency_source
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context "a mock lockfile with one source and a complex dependency" do
|
112
|
+
let(:lockfile) do
|
113
|
+
Helpers.strip_heredoc <<-LOCKFILE
|
114
|
+
MOCK
|
115
|
+
remote: source-a
|
116
|
+
specs:
|
117
|
+
butter (2.5.3)
|
118
|
+
jelly (1.3.5)
|
119
|
+
butter (< 3, >= 1.1)
|
120
|
+
|
121
|
+
DEPENDENCIES
|
122
|
+
jelly (!= 1.2.6, ~> 1.1)
|
123
|
+
|
124
|
+
LOCKFILE
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should give a list of one dependency" do
|
128
|
+
resolution.should have(1).dependencies
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should have the expected dependency" do
|
132
|
+
dependency = resolution.dependencies.first
|
133
|
+
|
134
|
+
dependency.name.should == "jelly"
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should give a list of all the manifests" do
|
138
|
+
resolution.should have(2).manifests
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should include all the expected manifests" do
|
142
|
+
manifests = ManifestSet.new(resolution.manifests)
|
143
|
+
|
144
|
+
manifests.to_hash.keys.should =~ %w(butter jelly)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should have an internally consistent set of manifests" do
|
148
|
+
manifests = ManifestSet.new(resolution.manifests)
|
149
|
+
|
150
|
+
manifests.should be_consistent
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should have an externally consistent set of manifests" do
|
154
|
+
dependencies = resolution.dependencies
|
155
|
+
manifests = ManifestSet.new(resolution.manifests)
|
156
|
+
|
157
|
+
manifests.should be_in_compliance_with dependencies
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'librarian'
|
2
|
+
require 'librarian/mock'
|
3
|
+
|
4
|
+
module Librarian
|
5
|
+
describe Lockfile do
|
6
|
+
|
7
|
+
let(:env) { Mock::Environment.new }
|
8
|
+
|
9
|
+
before do
|
10
|
+
env.registry :clear => true do
|
11
|
+
source 'source-1' do
|
12
|
+
spec 'alpha', '1.1'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:spec) do
|
18
|
+
env.dsl do
|
19
|
+
src 'source-1'
|
20
|
+
dep 'alpha', '1.1'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:resolver) { env.resolver }
|
25
|
+
let(:resolution) { resolver.resolve(spec) }
|
26
|
+
|
27
|
+
context "sanity" do
|
28
|
+
context "the resolution" do
|
29
|
+
subject { resolution }
|
30
|
+
|
31
|
+
it { should be_correct }
|
32
|
+
it { should have(1).manifests }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#save" do
|
37
|
+
let(:lockfile) { env.ephemeral_lockfile }
|
38
|
+
let(:lockfile_text) { lockfile.save(resolution) }
|
39
|
+
|
40
|
+
context "just saving" do
|
41
|
+
it "should return the lockfile text" do
|
42
|
+
lockfile_text.should_not be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "saving and reloading" do
|
47
|
+
let(:reloaded_resolution) { lockfile.load(lockfile_text) }
|
48
|
+
|
49
|
+
it "should have the expected manifests" do
|
50
|
+
reloaded_resolution.manifests.count.should == resolution.manifests.count
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "bouncing" do
|
55
|
+
let(:bounced_resolution) { lockfile.load(lockfile_text) }
|
56
|
+
let(:bounced_lockfile_text) { lockfile.save(bounced_resolution) }
|
57
|
+
|
58
|
+
it "should return the same lockfile text after bouncing as before bouncing" do
|
59
|
+
bounced_lockfile_text.should == lockfile_text
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
require 'librarian'
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
describe ManifestSet do
|
5
|
+
|
6
|
+
describe ".new" do
|
7
|
+
let(:jelly) { double(:name => "jelly") }
|
8
|
+
let(:butter) { double(:name => "butter") }
|
9
|
+
let(:jam) { double(:name => "jam") }
|
10
|
+
|
11
|
+
let(:array) { [jelly, butter, jam] }
|
12
|
+
let(:hash) { {"jelly" => jelly, "butter" => butter, "jam" => jam} }
|
13
|
+
|
14
|
+
context "with an array" do
|
15
|
+
let(:set) { described_class.new(array) }
|
16
|
+
|
17
|
+
it "should give back the array" do
|
18
|
+
set.to_a.should =~ array
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should give back the hash" do
|
22
|
+
set.to_hash.should == hash
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with a hash" do
|
27
|
+
let(:set) { described_class.new(hash) }
|
28
|
+
|
29
|
+
it "should give back the array" do
|
30
|
+
set.to_a.should =~ array
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should give back the hash" do
|
34
|
+
set.to_hash.should == hash
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Does not trace dependencies.
|
40
|
+
# That's why it's "shallow".
|
41
|
+
describe "#shallow_strip!" do
|
42
|
+
let(:jelly) { double(:name => "jelly") }
|
43
|
+
let(:butter) { double(:name => "butter") }
|
44
|
+
let(:jam) { double(:name => "jam") }
|
45
|
+
|
46
|
+
let(:set) { described_class.new([jelly, butter, jam]) }
|
47
|
+
|
48
|
+
it "should not do anything when given no names" do
|
49
|
+
set.shallow_strip!([])
|
50
|
+
|
51
|
+
set.to_a.should =~ [jelly, butter, jam]
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should remove only the named elements" do
|
55
|
+
set.shallow_strip!(["butter", "jam"])
|
56
|
+
|
57
|
+
set.to_a.should =~ [jelly]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should allow removing all the elements" do
|
61
|
+
set.shallow_strip!(["jelly", "butter", "jam"])
|
62
|
+
|
63
|
+
set.to_a.should =~ []
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Does not trace dependencies.
|
68
|
+
# That's why it's "shallow".
|
69
|
+
describe "#shallow_keep!" do
|
70
|
+
let(:jelly) { double(:name => "jelly") }
|
71
|
+
let(:butter) { double(:name => "butter") }
|
72
|
+
let(:jam) { double(:name => "jam") }
|
73
|
+
|
74
|
+
let(:set) { described_class.new([jelly, butter, jam]) }
|
75
|
+
|
76
|
+
it "should empty the set when given no names" do
|
77
|
+
set.shallow_keep!([])
|
78
|
+
|
79
|
+
set.to_a.should =~ []
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should keep only the named elements" do
|
83
|
+
set.shallow_keep!(["butter", "jam"])
|
84
|
+
|
85
|
+
set.to_a.should =~ [butter, jam]
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should allow keeping all the elements" do
|
89
|
+
set.shallow_keep!(["jelly", "butter", "jam"])
|
90
|
+
|
91
|
+
set.to_a.should =~ [jelly, butter, jam]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#deep_strip!" do
|
96
|
+
def man(o)
|
97
|
+
k, v = o.keys.first, o.values.first
|
98
|
+
double(k, :name => k, :dependencies => deps(v))
|
99
|
+
end
|
100
|
+
|
101
|
+
def deps(names)
|
102
|
+
names.map{|n| double(:name => n)}
|
103
|
+
end
|
104
|
+
|
105
|
+
let(:a) { man("a" => %w[b c]) }
|
106
|
+
let(:b) { man("b" => %w[c d]) }
|
107
|
+
let(:c) { man("c" => %w[ ]) }
|
108
|
+
let(:d) { man("d" => %w[ ]) }
|
109
|
+
|
110
|
+
let(:e) { man("e" => %w[f g]) }
|
111
|
+
let(:f) { man("f" => %w[g h]) }
|
112
|
+
let(:g) { man("g" => %w[ ]) }
|
113
|
+
let(:h) { man("h" => %w[ ]) }
|
114
|
+
|
115
|
+
let(:set) { described_class.new([a, b, c, d, e, f, g, h]) }
|
116
|
+
|
117
|
+
it "should not do anything when given no names" do
|
118
|
+
set.deep_strip!([])
|
119
|
+
|
120
|
+
set.to_a.should =~ [a, b, c, d, e, f, g, h]
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should remove just the named elements if they have no dependencies" do
|
124
|
+
set.deep_strip!(["c", "h"])
|
125
|
+
|
126
|
+
set.to_a.should =~ [a, b, d, e, f, g]
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should remove the named elements and all their dependencies" do
|
130
|
+
set.deep_strip!(["b"])
|
131
|
+
|
132
|
+
set.to_a.should =~ [a, e, f, g, h]
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should remove an entire tree of dependencies" do
|
136
|
+
set.deep_strip!(["e"])
|
137
|
+
|
138
|
+
set.to_a.should =~ [a, b, c, d]
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should allow removing all the elements" do
|
142
|
+
set.deep_strip!(["a", "e"])
|
143
|
+
|
144
|
+
set.to_a.should =~ []
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "#deep_keep!" do
|
149
|
+
def man(o)
|
150
|
+
k, v = o.keys.first, o.values.first
|
151
|
+
double(k, :name => k, :dependencies => deps(v))
|
152
|
+
end
|
153
|
+
|
154
|
+
def deps(names)
|
155
|
+
names.map{|n| double(:name => n)}
|
156
|
+
end
|
157
|
+
|
158
|
+
let(:a) { man("a" => %w[b c]) }
|
159
|
+
let(:b) { man("b" => %w[c d]) }
|
160
|
+
let(:c) { man("c" => %w[ ]) }
|
161
|
+
let(:d) { man("d" => %w[ ]) }
|
162
|
+
|
163
|
+
let(:e) { man("e" => %w[f g]) }
|
164
|
+
let(:f) { man("f" => %w[g h]) }
|
165
|
+
let(:g) { man("g" => %w[ ]) }
|
166
|
+
let(:h) { man("h" => %w[ ]) }
|
167
|
+
|
168
|
+
let(:set) { described_class.new([a, b, c, d, e, f, g, h]) }
|
169
|
+
|
170
|
+
it "should remove all the elements when given no names" do
|
171
|
+
set.deep_keep!([])
|
172
|
+
|
173
|
+
set.to_a.should =~ []
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should keep just the named elements if they have no dependencies" do
|
177
|
+
set.deep_keep!(["c", "h"])
|
178
|
+
|
179
|
+
set.to_a.should =~ [c, h]
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should keep the named elements and all their dependencies" do
|
183
|
+
set.deep_keep!(["b"])
|
184
|
+
|
185
|
+
set.to_a.should =~ [b, c, d]
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should keep an entire tree of dependencies" do
|
189
|
+
set.deep_keep!(["e"])
|
190
|
+
|
191
|
+
set.to_a.should =~ [e, f, g, h]
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should allow keeping all the elements" do
|
195
|
+
set.deep_keep!(["a", "e"])
|
196
|
+
|
197
|
+
set.to_a.should =~ [a, b, c, d, e, f, g, h]
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "librarian/manifest"
|
2
|
+
|
3
|
+
describe Librarian::Manifest do
|
4
|
+
|
5
|
+
describe "validations" do
|
6
|
+
|
7
|
+
context "when the name is blank" do
|
8
|
+
it "raises" do
|
9
|
+
expect { described_class.new(nil, "") }.
|
10
|
+
to raise_error(ArgumentError, %{name ("") must be sensible})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when the name has leading whitespace" do
|
15
|
+
it "raises" do
|
16
|
+
expect { described_class.new(nil, " the-name") }.
|
17
|
+
to raise_error(ArgumentError, %{name (" the-name") must be sensible})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when the name has trailing whitespace" do
|
22
|
+
it "raises" do
|
23
|
+
expect { described_class.new(nil, "the-name ") }.
|
24
|
+
to raise_error(ArgumentError, %{name ("the-name ") must be sensible})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the name is a single character" do
|
29
|
+
it "passes" do
|
30
|
+
described_class.new(nil, "R")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|