rubycut-babushka 0.10.8 → 0.15.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/Gemfile +1 -0
  2. data/Gemfile.lock +17 -15
  3. data/README.markdown +163 -41
  4. data/Rakefile +1 -1
  5. data/bin/babushka +1 -1
  6. data/deps/apt.rb +44 -0
  7. data/deps/babushka.rb +54 -42
  8. data/deps/deprecated.rb +16 -0
  9. data/deps/dev.rb +28 -3
  10. data/deps/git.rb +27 -12
  11. data/deps/homebrew.rb +2 -2
  12. data/deps/packages.rb +14 -15
  13. data/deps/pkg_managers.rb +21 -75
  14. data/deps/ruby.rb +5 -19
  15. data/deps/rubygems.rb +3 -3
  16. data/deps/system.rb +2 -2
  17. data/deps/templates/app.rb +60 -41
  18. data/deps/templates/bin.rb +16 -0
  19. data/deps/templates/installer.rb +9 -9
  20. data/deps/templates/lib.rb +17 -0
  21. data/deps/templates/managed.rb +1 -38
  22. data/deps/templates/src.rb +16 -8
  23. data/deps/templates/task.rb +11 -0
  24. data/deps/templates/tmbundle.rb +16 -2
  25. data/lib/babushka.rb +2 -3
  26. data/lib/babushka/accepts_block_for.rb +5 -3
  27. data/lib/babushka/asset.rb +172 -0
  28. data/lib/babushka/base.rb +37 -8
  29. data/lib/babushka/bug_reporter.rb +6 -6
  30. data/lib/babushka/cmdline.rb +11 -10
  31. data/lib/babushka/cmdline/handler.rb +7 -3
  32. data/lib/babushka/cmdline/helpers.rb +15 -23
  33. data/lib/babushka/cmdline/parser.rb +1 -1
  34. data/lib/babushka/core_patches/object.rb +1 -1
  35. data/lib/babushka/core_patches/string.rb +8 -3
  36. data/lib/babushka/current_ruby.rb +44 -0
  37. data/lib/babushka/dep.rb +111 -185
  38. data/lib/babushka/dep_context.rb +8 -3
  39. data/lib/babushka/dep_definer.rb +45 -15
  40. data/lib/babushka/dep_pool.rb +5 -8
  41. data/lib/babushka/{meta_dep.rb → dep_template.rb} +21 -2
  42. data/lib/babushka/dsl.rb +3 -0
  43. data/lib/babushka/git_repo.rb +143 -49
  44. data/lib/babushka/helpers/git_helpers.rb +7 -6
  45. data/lib/babushka/helpers/log_helpers.rb +51 -13
  46. data/lib/babushka/helpers/path_helpers.rb +5 -7
  47. data/lib/babushka/helpers/run_helpers.rb +15 -55
  48. data/lib/babushka/helpers/shell_helpers.rb +18 -26
  49. data/lib/babushka/helpers/uri_helpers.rb +9 -18
  50. data/lib/babushka/lambda_chooser.rb +20 -13
  51. data/lib/babushka/parameter.rb +20 -4
  52. data/lib/babushka/path_checker.rb +72 -0
  53. data/lib/babushka/pkg_helper.rb +38 -13
  54. data/lib/babushka/pkg_helpers/apt_helper.rb +15 -8
  55. data/lib/babushka/pkg_helpers/binpkgsrc_helper.rb +15 -14
  56. data/lib/babushka/pkg_helpers/binports_helper.rb +7 -7
  57. data/lib/babushka/pkg_helpers/brew_helper.rb +17 -25
  58. data/lib/babushka/pkg_helpers/gem_helper.rb +36 -27
  59. data/lib/babushka/pkg_helpers/npm_helper.rb +9 -9
  60. data/lib/babushka/pkg_helpers/pacman_helper.rb +5 -4
  61. data/lib/babushka/pkg_helpers/pip_helper.rb +14 -10
  62. data/lib/babushka/pkg_helpers/unknown_pkg_helper.rb +19 -0
  63. data/lib/babushka/pkg_helpers/yum_helper.rb +1 -1
  64. data/lib/babushka/popen.rb +13 -10
  65. data/lib/babushka/prompt.rb +14 -1
  66. data/lib/babushka/renderable.rb +11 -9
  67. data/lib/babushka/resource.rb +5 -166
  68. data/lib/babushka/run_reporter.rb +12 -3
  69. data/lib/babushka/shell.rb +54 -44
  70. data/lib/babushka/source.rb +41 -20
  71. data/lib/babushka/source_pool.rb +20 -13
  72. data/lib/babushka/system_definitions.rb +11 -3
  73. data/lib/babushka/system_detector.rb +31 -0
  74. data/lib/babushka/system_matcher.rb +53 -0
  75. data/lib/babushka/system_profile.rb +67 -89
  76. data/lib/babushka/task.rb +36 -8
  77. data/lib/babushka/{meta_dep_context.rb → templated_dep_context.rb} +1 -1
  78. data/lib/babushka/vars.rb +46 -4
  79. data/lib/babushka/version_of.rb +35 -17
  80. data/lib/babushka/version_str.rb +12 -8
  81. data/lib/components.rb +9 -8
  82. data/lib/fancypath/fancypath.rb +109 -83
  83. data/lib/inkan/inkan.rb +14 -14
  84. data/lib/{babushka → levenshtein}/levenshtein.rb +0 -0
  85. data/spec/acceptance/acceptance.rb +4 -4
  86. data/spec/acceptance_helper.rb +10 -6
  87. data/spec/babushka/accepts_for_spec.rb +137 -142
  88. data/spec/babushka/accepts_for_support.rb +13 -6
  89. data/spec/babushka/asset_spec.rb +165 -0
  90. data/spec/babushka/cmdline/help_spec.rb +11 -9
  91. data/spec/babushka/cmdline/meet_spec.rb +15 -0
  92. data/spec/babushka/cmdline/version_spec.rb +1 -1
  93. data/spec/babushka/core_patches_spec.rb +9 -0
  94. data/spec/babushka/current_ruby_spec.rb +73 -0
  95. data/spec/babushka/dep_context_spec.rb +27 -13
  96. data/spec/babushka/dep_definer_spec.rb +108 -16
  97. data/spec/babushka/dep_spec.rb +87 -104
  98. data/spec/babushka/dep_template_spec.rb +176 -0
  99. data/spec/babushka/deps_spec.rb +48 -19
  100. data/spec/babushka/gem_helper_spec.rb +46 -59
  101. data/spec/babushka/git_repo_spec.rb +242 -51
  102. data/spec/babushka/ip_spec.rb +11 -11
  103. data/spec/babushka/lambda_chooser_spec.rb +47 -9
  104. data/spec/babushka/parameter_spec.rb +21 -0
  105. data/spec/babushka/path_checker_spec.rb +35 -0
  106. data/spec/babushka/path_helpers_spec.rb +51 -50
  107. data/spec/babushka/prompt_spec.rb +4 -4
  108. data/spec/babushka/renderable_spec.rb +61 -28
  109. data/spec/babushka/shell_helpers_spec.rb +110 -85
  110. data/spec/babushka/shell_spec.rb +15 -0
  111. data/spec/babushka/source_pool_spec.rb +204 -210
  112. data/spec/babushka/source_spec.rb +125 -42
  113. data/spec/babushka/source_support.rb +1 -1
  114. data/spec/babushka/system_profile_spec.rb +86 -49
  115. data/spec/babushka/task_spec.rb +80 -13
  116. data/spec/babushka/vars_spec.rb +2 -1
  117. data/spec/babushka/version_of_spec.rb +29 -2
  118. data/spec/babushka/version_str_spec.rb +91 -65
  119. data/spec/babushka/xml_string_spec.rb +1 -1
  120. data/spec/deps/bad/broken.rb +2 -2
  121. data/spec/deps/bad/working.rb +0 -1
  122. data/spec/deps/good/{meta.rb → template.rb} +0 -0
  123. data/spec/deps/good/test.rb +0 -3
  124. data/spec/deps/outer/deps.rb +0 -2
  125. data/spec/fancypath/fancypath_spec.rb +30 -0
  126. data/spec/inkan/inkan_spec.rb +34 -32
  127. data/spec/spec_helper.rb +7 -50
  128. data/spec/system_detector_spec.rb +70 -0
  129. metadata +163 -177
  130. data/deps/os_x.rb +0 -33
  131. data/deps/templates/ppa.rb +0 -24
  132. data/lib/babushka/core_patches/io.rb +0 -8
  133. data/lib/babushka/dep_runner.rb +0 -85
  134. data/lib/babushka/helpers/suggest_helpers.rb +0 -16
  135. data/lib/babushka/pkg_helpers/base_helper.rb +0 -19
  136. data/lib/babushka/pkg_helpers/macports_helper.rb +0 -22
  137. data/spec/babushka/dep_definer_support.rb +0 -36
  138. data/spec/babushka/meta_dep_definer_spec.rb +0 -127
  139. data/spec/babushka/meta_dep_wrapper_spec.rb +0 -32
  140. data/spec/babushka/resource_spec.rb +0 -141
  141. data/spec/babushka/run_helpers_spec.rb +0 -26
  142. data/spec/babushka/source_pool_support.rb +0 -31
@@ -1,9 +1,96 @@
1
1
  require 'spec_helper'
2
- require 'dep_definer_support'
3
2
 
4
3
  describe "source_template" do
5
4
  it "should return BaseTemplate" do
6
- TestDepContext.source_template.should == Dep::BaseTemplate
5
+ DepContext.source_template.should == Dep::BaseTemplate
6
+ end
7
+ end
8
+
9
+ describe DepDefiner, '#define!' do
10
+ let(:a_dep) { dep('DepDefiner defining spec') }
11
+
12
+ it "should return itself" do
13
+ DepDefiner.new(a_dep).tap {|dd|
14
+ dd.define!.should == dd
15
+ }
16
+ end
17
+ it "shouldn't define straight away" do
18
+ DepDefiner.new(a_dep).tap {|dd|
19
+ dd.should_not be_loaded
20
+ dd.should_not be_failed
21
+ }
22
+ DepDefiner.new(a_dep) {}.tap {|dd|
23
+ dd.should_not be_loaded
24
+ dd.should_not be_failed
25
+ }
26
+ end
27
+ it "should define without a block" do
28
+ DepDefiner.new(a_dep).tap {|dd|
29
+ dd.define!
30
+ dd.should be_loaded
31
+ dd.should_not be_failed
32
+ }
33
+ end
34
+ it "should define with a valid block" do
35
+ DepDefiner.new(a_dep) {}.tap {|dd|
36
+ dd.define!
37
+ dd.should be_loaded
38
+ dd.should_not be_failed
39
+ }
40
+ end
41
+ it "should fail with an invalid block" do
42
+ DepDefiner.new(a_dep) { lol }.tap {|dd|
43
+ lambda { dd.define! }.should raise_error
44
+ dd.should_not be_loaded
45
+ dd.should be_failed
46
+ }
47
+ end
48
+ it "shouldn't define twice" do
49
+ DepDefiner.new(a_dep).tap {|dd|
50
+ dd.should_receive(:define_elements!).once
51
+ dd.define!
52
+ dd.define!
53
+ }
54
+ end
55
+ it "should allow DepDefinitionError to bubble up" do
56
+ lambda {
57
+ DepDefiner.new(a_dep) { raise DepDefinitionError }.define!
58
+ }.should raise_error(DepDefinitionError)
59
+ end
60
+ it "shouldn't attempt re-defining after failure" do
61
+ DepDefiner.new(a_dep).tap {|dd|
62
+ dd.stub!(:failed?).and_return(true)
63
+ dd.should_not_receive(:define_elements!)
64
+ }.define!
65
+ end
66
+ end
67
+
68
+ describe DepDefiner, '#invoke' do
69
+ let(:a_dep) { dep('DepDefiner invoking spec') }
70
+ let(:definer) { DepDefiner.new(a_dep) }
71
+
72
+ it "should define and invoke when undefined" do
73
+ definer.should_receive(:define!)
74
+ definer.should_receive(:met?).and_return(lambda {|_| })
75
+ definer.invoke(:met?)
76
+ end
77
+
78
+ it "should invoke only when already defined" do
79
+ definer.stub!(:loaded?).and_return(true)
80
+ definer.should_not_receive(:define!)
81
+ definer.should_receive(:met?).and_return(lambda {|_| })
82
+ definer.invoke(:met?)
83
+ end
84
+
85
+ it "should not invoke when defining failed" do
86
+ definer.should_receive(:define_elements!).and_raise(StandardError)
87
+ definer.should_not_receive(:met?)
88
+ lambda { definer.invoke(:met?) }.should raise_error
89
+ end
90
+
91
+ it "should call the task with a valid block" do
92
+ DepContext.new(a_dep) { }.invoke(:met?).should be_true
93
+ DepContext.new(a_dep) { met? { false } }.invoke(:met?).should be_false
7
94
  end
8
95
  end
9
96
 
@@ -103,12 +190,12 @@ describe "args" do
103
190
  subject.args.map_values {|_,v| v.name }.should == {:a => :a}
104
191
  end
105
192
  it "should lazily create the missing parameter" do
106
- subject.context.b.should be_an_instance_of(Parameter)
107
- subject.context.b.name.should == :b
193
+ subject.context.define!.b.should be_an_instance_of(Parameter)
194
+ subject.context.define!.b.name.should == :b
108
195
  end
109
196
  it "should set only the paramters that were passed" do
110
- subject.context.a.should be_set
111
- subject.context.b.should_not be_set
197
+ subject.context.define!.a.should be_set
198
+ subject.context.define!.b.should_not be_set
112
199
  end
113
200
  end
114
201
  end
@@ -123,30 +210,35 @@ describe "methods in deps" do
123
210
  dep 'without helper method'
124
211
  }
125
212
  it "should only be defined on the specified dep" do
126
- Dep('helper method test').context.should respond_to(:helper_test)
127
- Dep('without helper method').context.should_not respond_to(:helper_test)
213
+ Dep('helper method test').context.define!.should respond_to(:helper_test)
214
+ Dep('without helper method').context.define!.should_not respond_to(:helper_test)
128
215
  end
129
216
  it "should return the right value" do
130
- Dep('helper method test').context.helper_test.should == 'hello from the helper method!'
217
+ Dep('helper method test').context.define!.helper_test.should == 'hello from the helper method!'
131
218
  end
132
219
  end
133
220
 
134
221
  describe "#on for scoping accepters" do
222
+ let!(:the_lambda) { L{ 'hello from the lambda' } }
223
+ let!(:other_lambda) { L{ 'hello from the other lambda' } }
135
224
  before {
136
- Base.stub!(:host).and_return OSXSystemProfile.for_flavour
137
- Base.host.stub!(:version).and_return '10.6.7'
138
- @lambda = lambda = L{ 'hello from the lambda' }
139
- @other_lambda = other_lambda = L{ 'hello from the other lambda' }
225
+ Babushka.stub!(:host).and_return OSXSystemProfile.new
226
+ Babushka.host.stub!(:match_list).and_return([:osx])
227
+
228
+ local_lambda, other_local_lambda = the_lambda, other_lambda
229
+
140
230
  dep 'scoping' do
141
231
  on :osx do
142
- met?(&lambda)
232
+ met?(&local_lambda)
143
233
  end
144
234
  on :linux do
145
- met?(&other_lambda)
235
+ met?(&other_local_lambda)
146
236
  end
147
237
  end
148
238
  }
149
239
  it "should only allow choices that match" do
150
- Dep('scoping').send(:payload)[:met?].should == {:osx => @lambda}
240
+ Dep('scoping').tap {|dep|
241
+ dep.context.define!
242
+ }.context.payload[:met?].should == {:osx => the_lambda}
151
243
  end
152
244
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'dep_support'
3
5
 
@@ -14,6 +16,12 @@ describe "Dep.new" do
14
16
  }.should raise_error(InvalidDepName, "The dep name 'carriage\rreturn' contains nonprintable characters.")
15
17
  Dep("carriage\rreturn").should be_nil
16
18
  end
19
+ it "should allow deps with unicode characters in their names" do
20
+ L{
21
+ Dep.new "☕script", Base.sources.anonymous, [], {}, nil
22
+ }.should_not raise_error
23
+ Dep("☕script").should be_an_instance_of(Dep)
24
+ end
17
25
  it "should reject deps slashes in their names" do
18
26
  L{
19
27
  Dep.new "slashes/invalidate names", Base.sources.anonymous, [], {}, nil
@@ -21,6 +29,7 @@ describe "Dep.new" do
21
29
  Dep("slashes/invalidate names").should be_nil
22
30
  end
23
31
  it "should reject deps colons in their names" do
32
+ GitHelpers.stub!(:git) # To avoid cloning.
24
33
  L{
25
34
  Dep.new "colons:invalidate names", Base.sources.anonymous, [], {}, nil
26
35
  }.should raise_error(InvalidDepName, "The dep name 'colons:invalidate names' contains ':', which isn't allowed (colons separate dep and template names from source prefixes).")
@@ -83,7 +92,7 @@ describe Dep, '.find_or_suggest' do
83
92
  end
84
93
  context "namespaced" do
85
94
  before {
86
- Dep.stub!(:suggest_value_for).and_return(nil)
95
+ Prompt.stub!(:suggest_value_for).and_return(nil)
87
96
  @source = Source.new(nil, :name => 'namespaced')
88
97
  Source.stub!(:present).and_return([@source])
89
98
  Base.sources.load_context :source => @source do
@@ -91,9 +100,12 @@ describe Dep, '.find_or_suggest' do
91
100
  end
92
101
  }
93
102
  it "should not find the dep without a namespace" do
103
+ Babushka::Levenshtein.stub!(:distance).and_return(20) # For performance.
94
104
  Dep.find_or_suggest('namespaced Dep.find_or_suggest tests').should be_nil
95
105
  end
96
106
  it "should not find the dep with an incorrect namespace" do
107
+ Babushka::Levenshtein.stub!(:distance).and_return(20) # For performance.
108
+ GitHelpers.stub!(:git) # To avoid cloning.
97
109
  Dep.find_or_suggest('incorrect:namespaced Dep.find_or_suggest tests').should be_nil
98
110
  end
99
111
  it "should find the dep with the correct namespace" do
@@ -118,7 +130,7 @@ describe Dep, '.find_or_suggest' do
118
130
  @sub_dep = dep 'Dep.find_or_suggest sub-dep'
119
131
  }
120
132
  it "should find the sub dep" do
121
- @sub_dep.should_receive :process
133
+ @sub_dep.should_receive :process!
122
134
  @namespaced_dep.process
123
135
  end
124
136
  end
@@ -129,7 +141,7 @@ describe Dep, '.find_or_suggest' do
129
141
  end
130
142
  }
131
143
  it "should find the sub dep" do
132
- @sub_dep.should_receive :process
144
+ @sub_dep.should_receive :process!
133
145
  @namespaced_dep.process
134
146
  end
135
147
  end
@@ -228,18 +240,18 @@ describe Dep, "defining" do
228
240
  Base.sources.stub!(:current_real_load_source).and_return(Base.sources.anonymous)
229
241
  }
230
242
  it "should not define the dep when called without a block" do
231
- dep('lazy defining test').dep_defined?.should == nil
243
+ dep('lazy defining test').context.should_not be_loaded
232
244
  end
233
245
  it "should not define the dep when called with a block" do
234
246
  dep('lazy defining test with block') do
235
247
  requires 'another dep'
236
- end.dep_defined?.should == nil
248
+ end.context.should_not be_loaded
237
249
  end
238
250
  context "after running" do
239
251
  it "should be defined" do
240
252
  dep('lazy defining test with run').tap {|dep|
241
253
  dep.met?
242
- }.dep_defined?.should == true
254
+ }.context.should be_loaded
243
255
  end
244
256
  context "with a template" do
245
257
  let!(:template) { meta 'lazy_defining_template' }
@@ -250,6 +262,18 @@ describe Dep, "defining" do
250
262
  end
251
263
  end
252
264
  end
265
+ context "with params" do
266
+ it "should run against subsequent parameters" do
267
+ parameter = Parameter.new(:arg)
268
+ dep('parameter preserving', :arg) {
269
+ arg.default!('a default value')
270
+ }.tap {|dep|
271
+ dep.met?('some other value')
272
+ dep.met?(parameter)
273
+ }
274
+ parameter.description.should == 'arg: [default!: "a default value"]'
275
+ end
276
+ end
253
277
  context "with errors" do
254
278
  before {
255
279
  Base.sources.stub!(:current_real_load_source).and_return(Base.sources.anonymous)
@@ -258,26 +282,26 @@ describe Dep, "defining" do
258
282
  dep('lazy defining test with errors') do
259
283
  nonexistent_method
260
284
  end.tap {|dep|
261
- dep.dep_defined?.should == nil
285
+ dep.context.should_not be_loaded
262
286
  dep.met?
263
- }.dep_defined?.should == false
287
+ }.context.should be_failed
264
288
  end
265
- end
266
- context "repeatedly" do
267
- it "should only ever define the dep once" do
268
- dep('lazy defining test with repetition').tap {|dep|
269
- dep.met?
270
- dep.context.should_receive(:define!).never
271
- dep.met?
272
- }
289
+ it "should not attempt to run" do
290
+ dep('lazy defining test with errors') do
291
+ nonexistent_method
292
+ end.tap {|dep|
293
+ dep.should_not_receive(:process_deps)
294
+ dep.should_not_receive(:process_self)
295
+ }.met?
273
296
  end
274
- it "should not overwrite custom blocks" do
275
- dep('lazy defining test with block overwriting') do
276
- setup { 'initial' }
297
+ it "should not attempt to run later" do
298
+ dep('lazy defining test with errors') do
299
+ nonexistent_method
277
300
  end.tap {|dep|
278
- dep.context.setup { 'custom' }
279
- dep.send(:define!)
280
- }.send(:process_task, :setup).should == 'custom'
301
+ dep.met?
302
+ dep.should_not_receive(:process_deps)
303
+ dep.should_not_receive(:process_self)
304
+ }.met?
281
305
  end
282
306
  end
283
307
  end
@@ -320,6 +344,21 @@ describe Dep, '#basename' do
320
344
  end
321
345
  end
322
346
 
347
+ describe Dep, '#cache_key' do
348
+ it "should work for parameterless deps" do
349
+ dep('cache key, no params').cache_key.should == DepRequirement.new('cache key, no params', [])
350
+ end
351
+ it "should work for parameterised deps with no args" do
352
+ dep('cache key, no args', :arg1, :arg2).cache_key.should == DepRequirement.new('cache key, no args', [nil, nil])
353
+ end
354
+ it "should work for parameterised deps with named args" do
355
+ dep('cache key, named args', :arg1, :arg2).with(:arg2 => 'value').cache_key.should == DepRequirement.new('cache key, named args', [nil, 'value'])
356
+ end
357
+ it "should work for parameterised deps positional args" do
358
+ dep('cache key, positional args', :arg1, :arg2).with('value', 'another').cache_key.should == DepRequirement.new('cache key, positional args', ['value', 'another'])
359
+ end
360
+ end
361
+
323
362
  describe Dep, "params" do
324
363
  describe "non-symbol params" do
325
364
  it "should be rejected, singular" do
@@ -334,25 +373,30 @@ describe Dep, "params" do
334
373
  end
335
374
  end
336
375
  it "should define methods on the context" do
337
- dep('params test', :a_param).context.should respond_to(:a_param)
376
+ dep('params test', :a_param).context.define!.should respond_to(:a_param)
338
377
  end
339
378
  it "should raise on conflicting methods" do
340
379
  L{
341
- dep('conflicting param names', :name).context
380
+ dep('conflicting param names', :name).context.define!
342
381
  }.should raise_error(DepParameterError, "You can't use :name as a parameter (on 'conflicting param names'), because that's already a method on Babushka::DepDefiner.")
343
382
  end
383
+ it "should discard the context" do
384
+ dep('context discarding').tap {|dep|
385
+ dep.context.should_not == dep.with.context
386
+ }
387
+ end
344
388
  it "should not pollute other deps" do
345
389
  dep('params test', :a_param)
346
- Dep('params test').context.should respond_to(:a_param)
347
- dep('paramless dep').context.should_not respond_to(:a_param)
390
+ Dep('params test').context.define!.should respond_to(:a_param)
391
+ dep('paramless dep').context.define!.should_not respond_to(:a_param)
348
392
  end
349
393
  it "should return a param containing the value when it's set" do
350
394
  dep('set params test', :a_set_param)
351
- Dep('set params test').with('a value').context.a_set_param.should be_an_instance_of(Parameter)
352
- Dep('set params test').with('a value').context.a_set_param.to_s.should == 'a value'
395
+ Dep('set params test').with('a value').context.define!.a_set_param.should be_an_instance_of(Parameter)
396
+ Dep('set params test').with('a value').context.define!.a_set_param.to_s.should == 'a value'
353
397
  end
354
398
  it "should ask for the value when it's not set" do
355
- dep('unset params test', :an_unset_param)
399
+ dep('unset params test', :an_unset_param).context.define!
356
400
  Dep('unset params test').context.an_unset_param.should be_an_instance_of(Parameter)
357
401
  Prompt.should_receive(:get_value).with('an_unset_param', {}).and_return('a value from the prompt')
358
402
  Dep('unset params test').context.an_unset_param.to_s.should == 'a value from the prompt'
@@ -361,32 +405,34 @@ end
361
405
 
362
406
  describe Dep, 'lambda lists' do
363
407
  before {
364
- Babushka::Base.host.stub!(:name).and_return(:test_name)
365
- Babushka::Base.host.stub!(:system).and_return(:test_system)
366
- Babushka::Base.host.stub!(:pkg_helper_key).and_return(:test_helper)
408
+ Babushka.host.matcher.stub!(:name).and_return(:test_name)
409
+ Babushka.host.matcher.stub!(:system).and_return(:test_system)
410
+ Babushka.host.matcher.stub!(:pkg_helper_key).and_return(:test_helper)
367
411
 
368
412
  Babushka::SystemDefinitions.stub!(:all_names).and_return([:test_name, :other_name])
369
413
  Babushka::SystemDefinitions.stub!(:all_systems).and_return([:test_system, :other_system])
370
414
  Babushka::PkgHelper.stub!(:all_manager_keys).and_return([:test_helper, :other_helper])
371
415
  }
372
416
  it "should match against the system name" do
373
- dep('lambda list name match') { requires { on :test_name, 'awesome' } }.context.requires.should == ['awesome']
417
+ dep('lambda list name match') { requires { on :test_name, 'awesome' } }.context.define!.requires.should == ['awesome']
374
418
  end
375
419
  it "should match against the system type" do
376
- dep('lambda list system match') { requires { on :test_system, 'awesome' } }.context.requires.should == ['awesome']
420
+ dep('lambda list system match') { requires { on :test_system, 'awesome' } }.context.define!.requires.should == ['awesome']
377
421
  end
378
422
  it "should match against the system name" do
379
- dep('lambda list pkg_helper_key match') { requires { on :test_helper, 'awesome' } }.context.requires.should == ['awesome']
423
+ dep('lambda list pkg_helper_key match') { requires { on :test_helper, 'awesome' } }.context.define!.requires.should == ['awesome']
380
424
  end
381
425
  end
382
426
 
383
427
  describe Dep, '#requirements_for' do
384
428
  let(:dependency) {
385
- dep 'requirements_for specs' do
429
+ dep('requirements_for specs') {
386
430
  requires 'a dep'
387
431
  requires 'another dep'.with(:some, :args)
388
432
  requires 'a third'.with()
389
- end
433
+ }.tap {|d|
434
+ d.context.define!
435
+ }
390
436
  }
391
437
  let(:requirements) {
392
438
  dependency.send(:requirements_for, :requires)
@@ -394,8 +440,8 @@ describe Dep, '#requirements_for' do
394
440
  it "should have the right number of requirements" do
395
441
  requirements.length.should == 3
396
442
  end
397
- it "should return a Requirement for all the required deps" do
398
- requirements.each {|c| c.should be_an_instance_of(Babushka::Dep::Requirement) }
443
+ it "should return a DepRequirement for all the required deps" do
444
+ requirements.each {|c| c.should be_an_instance_of(Babushka::DepRequirement) }
399
445
  end
400
446
  it "should contain the right dep names" do
401
447
  requirements.map(&:name).should == ['a dep', 'another dep', 'a third']
@@ -466,7 +512,7 @@ describe "calling meet on a single dep" do
466
512
  end
467
513
  it "should fail fast and return nil on explicitly unmeetable deps" do
468
514
  make_counter_dep(
469
- :name => 'explicitly unmeetable', :met? => L{ unmeetable }
515
+ :name => 'explicitly unmeetable', :met? => L{ unmeetable! }
470
516
  ).meet.should == nil
471
517
  @yield_counts['explicitly unmeetable'].should == @yield_counts_met_run
472
518
  end
@@ -484,7 +530,7 @@ describe "calling meet on a single dep" do
484
530
  end
485
531
  it "should fail, not run meet, and fail again on unmet deps where meet raises UnmeetableDep" do
486
532
  make_counter_dep(
487
- :name => 'unmet, #before fails', :met? => L{ false }, :meet => L{ unmeetable }
533
+ :name => 'unmet, #before fails', :met? => L{ false }, :meet => L{ unmeetable! }
488
534
  ).meet.should == nil
489
535
  @yield_counts['unmet, #before fails'].should == @yield_counts_early_exit_meet_run
490
536
  end
@@ -502,66 +548,3 @@ describe "calling meet on a single dep" do
502
548
  end
503
549
  after { Base.sources.anonymous.deps.clear! }
504
550
  end
505
-
506
- describe "run_in" do
507
- it "should run in the current directory when run_in isn't set" do
508
- cwd = Dir.pwd
509
- ran_in = nil
510
- dep 'dep without run_in set' do
511
- met? { ran_in = Dir.pwd }
512
- end.met?
513
- Dir.pwd.should == cwd
514
- ran_in.should == cwd
515
- end
516
- it "should not run when run_in is set to a nonexistent directory" do
517
- ran_in = nil
518
- dep 'dep with run_in set' do
519
- run_in tmp_prefix / 'nonexistent'
520
- met? { ran_in = Dir.pwd }
521
- end.met?
522
- ran_in.should be_nil
523
- end
524
- it "should run in the specified directory when run_in is set" do
525
- cwd = Dir.pwd
526
- ran_in = nil
527
- dep 'dep with run_in set' do
528
- run_in tmp_prefix
529
- met? { ran_in = Dir.pwd }
530
- end.met?
531
- Dir.pwd.should == cwd
532
- ran_in.should == tmp_prefix
533
- end
534
- it "should run this deps' requirements in the original directory" do
535
- cwd = Dir.pwd
536
- ran_in = child_ran_in = nil
537
- dep 'another without run_in set' do
538
- met? { child_ran_in = Dir.pwd }
539
- end
540
- dep 'dep with run_in set' do
541
- requires 'another without run_in set'
542
- run_in tmp_prefix
543
- met? { ran_in = Dir.pwd }
544
- end.met?
545
- Dir.pwd.should == cwd
546
- ran_in.should == tmp_prefix
547
- child_ran_in.should == cwd
548
- end
549
- it "should run this deps' requirements in their own directories when specified" do
550
- cwd = Dir.pwd
551
- ran_in = child_ran_in = nil
552
- (tmp_prefix / 'run_in').mkdir
553
- dep 'another with run_in set' do
554
- run_in tmp_prefix / 'run_in'
555
- met? { child_ran_in = Dir.pwd }
556
- end
557
- dep 'dep with run_in set' do
558
- requires 'another with run_in set'
559
- run_in tmp_prefix
560
- met? { ran_in = Dir.pwd }
561
- end.met?
562
- Dir.pwd.should == cwd
563
- ran_in.should == tmp_prefix
564
- child_ran_in.should == tmp_prefix / 'run_in'
565
- end
566
- after { Base.sources.anonymous.deps.clear! }
567
- end