librarian 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -10,25 +10,30 @@ module Librarian
10
10
 
11
11
  context "a simple specfile" do
12
12
 
13
- it "should work" do
13
+ before do
14
14
  env.registry :clear => true do
15
15
  source 'source-1' do
16
16
  spec 'butter', '1.1'
17
17
  end
18
18
  end
19
- spec = env.dsl do
19
+ end
20
+
21
+ let(:spec) do
22
+ env.dsl do
20
23
  src 'source-1'
21
24
  dep 'butter'
22
25
  end
23
- resolution = resolver.resolve(spec)
24
- resolution.should be_correct
25
26
  end
26
27
 
28
+ let(:resolution) { resolver.resolve(spec) }
29
+
30
+ specify { resolution.should be_correct }
31
+
27
32
  end
28
33
 
29
34
  context "a specfile with a dep from one src depending on a dep from another src" do
30
35
 
31
- it "should work" do
36
+ before do
32
37
  env.registry :clear => true do
33
38
  source 'source-1' do
34
39
  spec 'butter', '1.1'
@@ -39,21 +44,26 @@ module Librarian
39
44
  end
40
45
  end
41
46
  end
42
- spec = env.dsl do
47
+ end
48
+
49
+ let(:spec) do
50
+ env.dsl do
43
51
  src 'source-1'
44
52
  src 'source-2' do
45
53
  dep 'jam'
46
54
  end
47
55
  end
48
- resolution = resolver.resolve(spec)
49
- resolution.should be_correct
50
56
  end
51
57
 
58
+ let(:resolution) { resolver.resolve(spec) }
59
+
60
+ specify { resolution.should be_correct }
61
+
52
62
  end
53
63
 
54
64
  context "a specfile with a dep depending on a nonexistent dep" do
55
65
 
56
- it "should not work" do
66
+ before do
57
67
  env.registry :clear => true do
58
68
  source 'source-1' do
59
69
  spec 'jam', '1.2' do
@@ -61,19 +71,24 @@ module Librarian
61
71
  end
62
72
  end
63
73
  end
64
- spec = env.dsl do
74
+ end
75
+
76
+ let(:spec) do
77
+ env.dsl do
65
78
  src 'source-1'
66
79
  dep 'jam'
67
80
  end
68
- resolution = resolver.resolve(spec)
69
- resolution.should_not be_correct
70
81
  end
71
82
 
83
+ let(:resolution) { resolver.resolve(spec) }
84
+
85
+ specify { resolution.should_not be_correct }
86
+
72
87
  end
73
88
 
74
89
  context "a specfile with conflicting constraints" do
75
90
 
76
- it "should not work" do
91
+ before do
77
92
  env.registry :clear => true do
78
93
  source 'source-1' do
79
94
  spec 'butter', '1.0'
@@ -83,15 +98,20 @@ module Librarian
83
98
  end
84
99
  end
85
100
  end
86
- spec = env.dsl do
101
+ end
102
+
103
+ let(:spec) do
104
+ env.dsl do
87
105
  src 'source-1'
88
106
  dep 'butter', '1.0'
89
107
  dep 'jam'
90
108
  end
91
- resolution = resolver.resolve(spec)
92
- resolution.should_not be_correct
93
109
  end
94
110
 
111
+ let(:resolution) { resolver.resolve(spec) }
112
+
113
+ specify { resolution.should_not be_correct }
114
+
95
115
  end
96
116
 
97
117
  context "updating" do
@@ -0,0 +1,29 @@
1
+ require "librarian"
2
+
3
+ module Librarian
4
+ module Source
5
+ describe Git do
6
+
7
+ let(:env) { Environment.new }
8
+
9
+ describe "validating options for the specfile" do
10
+
11
+ context "with only known options" do
12
+ it "should not raise" do
13
+ expect { described_class.from_spec_args(env, "some://git/repo.git", :ref => "megapatches") }.
14
+ to_not raise_error
15
+ end
16
+ end
17
+
18
+ context "with an unknown option" do
19
+ it "should raise" do
20
+ expect { described_class.from_spec_args(env, "some://git/repo.git", :branch => "megapatches") }.
21
+ to raise_error Error, "unrecognized options: branch"
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-23 00:00:00.000000000 Z
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &9877880 !ruby/object:Gem::Requirement
16
+ requirement: &19516800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '0.15'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9877880
24
+ version_requirements: *19516800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &9877220 !ruby/object:Gem::Requirement
27
+ requirement: &19496240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *9877220
35
+ version_requirements: *19496240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &9876800 !ruby/object:Gem::Requirement
38
+ requirement: &19493040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *9876800
46
+ version_requirements: *19493040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cucumber
49
- requirement: &9876380 !ruby/object:Gem::Requirement
49
+ requirement: &19491840 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *9876380
57
+ version_requirements: *19491840
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: aruba
60
- requirement: &9875940 !ruby/object:Gem::Requirement
60
+ requirement: &19490840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *9875940
68
+ version_requirements: *19490840
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &9875500 !ruby/object:Gem::Requirement
71
+ requirement: &19489740 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *9875500
79
+ version_requirements: *19489740
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: chef
82
- requirement: &9874980 !ruby/object:Gem::Requirement
82
+ requirement: &19487700 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0.10'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *9874980
90
+ version_requirements: *19487700
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: highline
93
- requirement: &9874560 !ruby/object:Gem::Requirement
93
+ requirement: &19485200 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *9874560
101
+ version_requirements: *19485200
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: archive-tar-minitar
104
- requirement: &9874020 !ruby/object:Gem::Requirement
104
+ requirement: &19482760 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: 0.5.2
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *9874020
112
+ version_requirements: *19482760
113
113
  description: Librarian
114
114
  email:
115
115
  - y_feldblum@yahoo.com
@@ -132,6 +132,7 @@ files:
132
132
  - config/cucumber.yaml
133
133
  - features/chef/cli/init.feature
134
134
  - features/chef/cli/install.feature
135
+ - features/chef/cli/show.feature
135
136
  - features/chef/cli/version.feature
136
137
  - features/support/env.rb
137
138
  - lib/librarian.rb
@@ -148,16 +149,15 @@ files:
148
149
  - lib/librarian/chef/environment.rb
149
150
  - lib/librarian/chef/extension.rb
150
151
  - lib/librarian/chef/integration/knife.rb
151
- - lib/librarian/chef/manifest.rb
152
+ - lib/librarian/chef/manifest_reader.rb
152
153
  - lib/librarian/chef/source.rb
153
154
  - lib/librarian/chef/source/git.rb
154
155
  - lib/librarian/chef/source/local.rb
155
- - lib/librarian/chef/source/local/manifest.rb
156
156
  - lib/librarian/chef/source/path.rb
157
157
  - lib/librarian/chef/source/site.rb
158
- - lib/librarian/chef/source/site/manifest.rb
159
158
  - lib/librarian/chef/templates/Cheffile
160
159
  - lib/librarian/cli.rb
160
+ - lib/librarian/cli/manifest_presenter.rb
161
161
  - lib/librarian/dependency.rb
162
162
  - lib/librarian/dsl.rb
163
163
  - lib/librarian/dsl/receiver.rb
@@ -204,9 +204,11 @@ files:
204
204
  - spec/unit/dsl_spec.rb
205
205
  - spec/unit/environment_spec.rb
206
206
  - spec/unit/lockfile_spec.rb
207
+ - spec/unit/manifest_set_spec.rb
207
208
  - spec/unit/manifest_spec.rb
208
209
  - spec/unit/mock/source/mock.rb
209
210
  - spec/unit/resolver_spec.rb
211
+ - spec/unit/source/git_spec.rb
210
212
  - spec/unit/spec_change_set_spec.rb
211
213
  homepage: ''
212
214
  licenses: []
@@ -233,3 +235,4 @@ signing_key:
233
235
  specification_version: 3
234
236
  summary: Librarian
235
237
  test_files: []
238
+ has_rdoc: