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.
- data/Gemfile +1 -0
- data/Gemfile.lock +17 -15
- data/README.markdown +163 -41
- data/Rakefile +1 -1
- data/bin/babushka +1 -1
- data/deps/apt.rb +44 -0
- data/deps/babushka.rb +54 -42
- data/deps/deprecated.rb +16 -0
- data/deps/dev.rb +28 -3
- data/deps/git.rb +27 -12
- data/deps/homebrew.rb +2 -2
- data/deps/packages.rb +14 -15
- data/deps/pkg_managers.rb +21 -75
- data/deps/ruby.rb +5 -19
- data/deps/rubygems.rb +3 -3
- data/deps/system.rb +2 -2
- data/deps/templates/app.rb +60 -41
- data/deps/templates/bin.rb +16 -0
- data/deps/templates/installer.rb +9 -9
- data/deps/templates/lib.rb +17 -0
- data/deps/templates/managed.rb +1 -38
- data/deps/templates/src.rb +16 -8
- data/deps/templates/task.rb +11 -0
- data/deps/templates/tmbundle.rb +16 -2
- data/lib/babushka.rb +2 -3
- data/lib/babushka/accepts_block_for.rb +5 -3
- data/lib/babushka/asset.rb +172 -0
- data/lib/babushka/base.rb +37 -8
- data/lib/babushka/bug_reporter.rb +6 -6
- data/lib/babushka/cmdline.rb +11 -10
- data/lib/babushka/cmdline/handler.rb +7 -3
- data/lib/babushka/cmdline/helpers.rb +15 -23
- data/lib/babushka/cmdline/parser.rb +1 -1
- data/lib/babushka/core_patches/object.rb +1 -1
- data/lib/babushka/core_patches/string.rb +8 -3
- data/lib/babushka/current_ruby.rb +44 -0
- data/lib/babushka/dep.rb +111 -185
- data/lib/babushka/dep_context.rb +8 -3
- data/lib/babushka/dep_definer.rb +45 -15
- data/lib/babushka/dep_pool.rb +5 -8
- data/lib/babushka/{meta_dep.rb → dep_template.rb} +21 -2
- data/lib/babushka/dsl.rb +3 -0
- data/lib/babushka/git_repo.rb +143 -49
- data/lib/babushka/helpers/git_helpers.rb +7 -6
- data/lib/babushka/helpers/log_helpers.rb +51 -13
- data/lib/babushka/helpers/path_helpers.rb +5 -7
- data/lib/babushka/helpers/run_helpers.rb +15 -55
- data/lib/babushka/helpers/shell_helpers.rb +18 -26
- data/lib/babushka/helpers/uri_helpers.rb +9 -18
- data/lib/babushka/lambda_chooser.rb +20 -13
- data/lib/babushka/parameter.rb +20 -4
- data/lib/babushka/path_checker.rb +72 -0
- data/lib/babushka/pkg_helper.rb +38 -13
- data/lib/babushka/pkg_helpers/apt_helper.rb +15 -8
- data/lib/babushka/pkg_helpers/binpkgsrc_helper.rb +15 -14
- data/lib/babushka/pkg_helpers/binports_helper.rb +7 -7
- data/lib/babushka/pkg_helpers/brew_helper.rb +17 -25
- data/lib/babushka/pkg_helpers/gem_helper.rb +36 -27
- data/lib/babushka/pkg_helpers/npm_helper.rb +9 -9
- data/lib/babushka/pkg_helpers/pacman_helper.rb +5 -4
- data/lib/babushka/pkg_helpers/pip_helper.rb +14 -10
- data/lib/babushka/pkg_helpers/unknown_pkg_helper.rb +19 -0
- data/lib/babushka/pkg_helpers/yum_helper.rb +1 -1
- data/lib/babushka/popen.rb +13 -10
- data/lib/babushka/prompt.rb +14 -1
- data/lib/babushka/renderable.rb +11 -9
- data/lib/babushka/resource.rb +5 -166
- data/lib/babushka/run_reporter.rb +12 -3
- data/lib/babushka/shell.rb +54 -44
- data/lib/babushka/source.rb +41 -20
- data/lib/babushka/source_pool.rb +20 -13
- data/lib/babushka/system_definitions.rb +11 -3
- data/lib/babushka/system_detector.rb +31 -0
- data/lib/babushka/system_matcher.rb +53 -0
- data/lib/babushka/system_profile.rb +67 -89
- data/lib/babushka/task.rb +36 -8
- data/lib/babushka/{meta_dep_context.rb → templated_dep_context.rb} +1 -1
- data/lib/babushka/vars.rb +46 -4
- data/lib/babushka/version_of.rb +35 -17
- data/lib/babushka/version_str.rb +12 -8
- data/lib/components.rb +9 -8
- data/lib/fancypath/fancypath.rb +109 -83
- data/lib/inkan/inkan.rb +14 -14
- data/lib/{babushka → levenshtein}/levenshtein.rb +0 -0
- data/spec/acceptance/acceptance.rb +4 -4
- data/spec/acceptance_helper.rb +10 -6
- data/spec/babushka/accepts_for_spec.rb +137 -142
- data/spec/babushka/accepts_for_support.rb +13 -6
- data/spec/babushka/asset_spec.rb +165 -0
- data/spec/babushka/cmdline/help_spec.rb +11 -9
- data/spec/babushka/cmdline/meet_spec.rb +15 -0
- data/spec/babushka/cmdline/version_spec.rb +1 -1
- data/spec/babushka/core_patches_spec.rb +9 -0
- data/spec/babushka/current_ruby_spec.rb +73 -0
- data/spec/babushka/dep_context_spec.rb +27 -13
- data/spec/babushka/dep_definer_spec.rb +108 -16
- data/spec/babushka/dep_spec.rb +87 -104
- data/spec/babushka/dep_template_spec.rb +176 -0
- data/spec/babushka/deps_spec.rb +48 -19
- data/spec/babushka/gem_helper_spec.rb +46 -59
- data/spec/babushka/git_repo_spec.rb +242 -51
- data/spec/babushka/ip_spec.rb +11 -11
- data/spec/babushka/lambda_chooser_spec.rb +47 -9
- data/spec/babushka/parameter_spec.rb +21 -0
- data/spec/babushka/path_checker_spec.rb +35 -0
- data/spec/babushka/path_helpers_spec.rb +51 -50
- data/spec/babushka/prompt_spec.rb +4 -4
- data/spec/babushka/renderable_spec.rb +61 -28
- data/spec/babushka/shell_helpers_spec.rb +110 -85
- data/spec/babushka/shell_spec.rb +15 -0
- data/spec/babushka/source_pool_spec.rb +204 -210
- data/spec/babushka/source_spec.rb +125 -42
- data/spec/babushka/source_support.rb +1 -1
- data/spec/babushka/system_profile_spec.rb +86 -49
- data/spec/babushka/task_spec.rb +80 -13
- data/spec/babushka/vars_spec.rb +2 -1
- data/spec/babushka/version_of_spec.rb +29 -2
- data/spec/babushka/version_str_spec.rb +91 -65
- data/spec/babushka/xml_string_spec.rb +1 -1
- data/spec/deps/bad/broken.rb +2 -2
- data/spec/deps/bad/working.rb +0 -1
- data/spec/deps/good/{meta.rb → template.rb} +0 -0
- data/spec/deps/good/test.rb +0 -3
- data/spec/deps/outer/deps.rb +0 -2
- data/spec/fancypath/fancypath_spec.rb +30 -0
- data/spec/inkan/inkan_spec.rb +34 -32
- data/spec/spec_helper.rb +7 -50
- data/spec/system_detector_spec.rb +70 -0
- metadata +163 -177
- data/deps/os_x.rb +0 -33
- data/deps/templates/ppa.rb +0 -24
- data/lib/babushka/core_patches/io.rb +0 -8
- data/lib/babushka/dep_runner.rb +0 -85
- data/lib/babushka/helpers/suggest_helpers.rb +0 -16
- data/lib/babushka/pkg_helpers/base_helper.rb +0 -19
- data/lib/babushka/pkg_helpers/macports_helper.rb +0 -22
- data/spec/babushka/dep_definer_support.rb +0 -36
- data/spec/babushka/meta_dep_definer_spec.rb +0 -127
- data/spec/babushka/meta_dep_wrapper_spec.rb +0 -32
- data/spec/babushka/resource_spec.rb +0 -141
- data/spec/babushka/run_helpers_spec.rb +0 -26
- data/spec/babushka/source_pool_support.rb +0 -31
data/lib/inkan/inkan.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Inkan
|
2
2
|
attr_accessor :credit, :comment, :comment_suffix
|
3
|
-
|
3
|
+
|
4
4
|
def self.legitimate?(filename)
|
5
5
|
File.open(filename) do |file|
|
6
6
|
file_content = file.read
|
@@ -14,43 +14,43 @@ class Inkan
|
|
14
14
|
!seal[/\s#{sha(content || '')}\s*$/].nil?
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def self.seal(file)
|
19
19
|
new(file).tap {|inkan| yield inkan }.seal
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def self.render
|
23
23
|
new(nil).tap {|inkan| yield inkan }.render
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def self.sha(content)
|
27
27
|
require 'digest/sha1'
|
28
28
|
Digest::SHA1.hexdigest(content)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def initialize(file)
|
32
32
|
@file = file
|
33
|
-
|
33
|
+
|
34
34
|
# Set Defaults
|
35
35
|
@credit = 'Generated by Inkan'
|
36
36
|
@comment = '#'
|
37
37
|
@comment_suffix = ''
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def print(string)
|
41
41
|
file_content << string
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def puts(string)
|
45
45
|
file_content << string << "\n"
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def seal
|
49
49
|
File.open(@file, 'w') do |f|
|
50
50
|
f.print render
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def render
|
55
55
|
if file_content[/\A#!/]
|
56
56
|
hashbang, remaining_content = file_content.split("\n", 2)
|
@@ -59,17 +59,17 @@ class Inkan
|
|
59
59
|
"#{render_seal}\n#{file_content}"
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
private
|
64
|
-
|
64
|
+
|
65
65
|
def render_seal
|
66
66
|
"#{comment} #{credit}. #{sha} #{comment_suffix}"
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def sha
|
70
70
|
self.class.sha(file_content)
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def file_content
|
74
74
|
@file_content ||= ''
|
75
75
|
end
|
File without changes
|
@@ -8,7 +8,7 @@ describe "babushka" do
|
|
8
8
|
|
9
9
|
context "basics" do
|
10
10
|
it "should have installed babushka" do
|
11
|
-
@vm.run('babushka --version').should =~ /^[\d.]
|
11
|
+
@vm.run('babushka --version').should =~ /^[\d.]+ \(\w{7}\)$/
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -23,11 +23,11 @@ describe "babushka" do
|
|
23
23
|
@vm.babushka('benhoskings:system') # once to set the locale
|
24
24
|
@vm.should meet('benhoskings:system')
|
25
25
|
end
|
26
|
-
it "should build ruby
|
27
|
-
@vm.should meet('benhoskings:
|
26
|
+
it "should build a recent ruby" do
|
27
|
+
@vm.should meet('benhoskings:ruby.src')
|
28
28
|
end
|
29
29
|
it "should set up nginx" do
|
30
|
-
@vm.should meet('benhoskings:
|
30
|
+
@vm.should meet('benhoskings:running.nginx')
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
data/spec/acceptance_helper.rb
CHANGED
@@ -7,8 +7,8 @@ require 'cloudservers'
|
|
7
7
|
require 'spec_helper'
|
8
8
|
|
9
9
|
class Babushka::Logging
|
10
|
-
def self.
|
11
|
-
|
10
|
+
def self.write_to_persistent_log message
|
11
|
+
# Don't overwrite logs when running acceptance specs.
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -20,7 +20,7 @@ class VM
|
|
20
20
|
SERVER_NAME = 'babushka-specs'
|
21
21
|
|
22
22
|
def babushka task
|
23
|
-
run("babushka \"#{task}\" --defaults
|
23
|
+
run("babushka \"#{task}\" --defaults").tap {|result|
|
24
24
|
# Fetch the debug log if the dep failed
|
25
25
|
run "cat ~/.babushka/logs/\"#{task}\"" unless result
|
26
26
|
}
|
@@ -83,11 +83,13 @@ class VM
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def image
|
86
|
-
connection.list_images.detect {|image| image[:name][cfg['image_name']] }
|
86
|
+
connection.list_images.detect {|image| image[:name][cfg['image_name']] } ||
|
87
|
+
raise(RuntimeError, "Couldn't find an image that matched '#{cfg['image_name']}'.")
|
87
88
|
end
|
88
89
|
|
89
90
|
def flavor
|
90
|
-
connection.list_flavors.detect {|flavor| flavor[:ram] == 256 }
|
91
|
+
connection.list_flavors.detect {|flavor| flavor[:ram] == 256 } ||
|
92
|
+
raise(RuntimeError, "Couldn't find the specs for a 256MB instance.")
|
91
93
|
end
|
92
94
|
|
93
95
|
def connection
|
@@ -95,9 +97,11 @@ class VM
|
|
95
97
|
:username => cfg['username'], :api_key => cfg['api_key']
|
96
98
|
)
|
97
99
|
end
|
100
|
+
|
98
101
|
def cfg
|
99
102
|
@_cfg ||= YAML.load_file(Babushka::Path.path / 'conf/rackspace.yml')
|
100
103
|
end
|
104
|
+
|
101
105
|
def public_key
|
102
106
|
Dir.glob(File.expand_path("~/.ssh/id_[dr]sa.pub")).first
|
103
107
|
end
|
@@ -108,6 +112,6 @@ RSpec::Matchers.define :meet do |expected|
|
|
108
112
|
vm.babushka(expected).should =~ /^\} ✓ #{Regexp.escape(expected)}\z/
|
109
113
|
}
|
110
114
|
failure_message_for_should {|vm|
|
111
|
-
"The '#{expected}' dep couldn't
|
115
|
+
"The '#{expected}' dep couldn't be met."
|
112
116
|
}
|
113
117
|
end
|
@@ -1,174 +1,169 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'accepts_for_support'
|
3
3
|
|
4
|
-
describe "
|
5
|
-
|
6
|
-
L{
|
7
|
-
AcceptsForTest.new.records "stuff" do
|
8
|
-
more "stuff"
|
9
|
-
end
|
10
|
-
}.should raise_error(ArgumentError, "You can supply arguments or a block, but not both.")
|
11
|
-
end
|
12
|
-
end
|
4
|
+
describe "accepts_*_for" do
|
5
|
+
subject { AcceptsForTest.new }
|
13
6
|
|
14
|
-
describe "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@list.send(method_name, "hello").should == @list
|
23
|
-
}
|
7
|
+
describe "invalid input" do
|
8
|
+
it "should reject values and a block at once" do
|
9
|
+
L{
|
10
|
+
subject.records "stuff" do
|
11
|
+
more "stuff"
|
12
|
+
end
|
13
|
+
}.should raise_error(ArgumentError, "You can supply arguments or a block, but not both.")
|
14
|
+
end
|
24
15
|
end
|
25
|
-
end
|
26
16
|
|
27
|
-
describe "
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@value.renders.should == "a default response"
|
36
|
-
@value.format.should == "json"
|
37
|
-
end
|
38
|
-
it "should return the value when called without args" do
|
39
|
-
[:package, :renders, :format].each {|method_name|
|
40
|
-
@value.send(method_name, "hello").send(method_name).should == "hello"
|
41
|
-
}
|
42
|
-
end
|
43
|
-
it "should return the result of callable items" do
|
44
|
-
[:package, :renders, :format].each {|method_name|
|
45
|
-
@value.send(method_name, L{ "world" }).send(method_name).should == "world"
|
46
|
-
}
|
47
|
-
end
|
48
|
-
it "should replace existing values with new ones" do
|
49
|
-
@value.package "ruby-1.8"
|
50
|
-
@value.package "ruby-1.9"
|
51
|
-
@value.package.should == "ruby-1.9"
|
17
|
+
describe "storing" do
|
18
|
+
it "should return self to allow chaining" do
|
19
|
+
[
|
20
|
+
:package, :renders, :format, :records, :produces, :valid_formats
|
21
|
+
].each {|method_name|
|
22
|
+
subject.send(method_name, "hello").should == subject
|
23
|
+
}
|
24
|
+
end
|
52
25
|
end
|
53
|
-
end
|
54
26
|
|
55
|
-
describe "accepts_value_for
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
27
|
+
describe "accepts_value_for" do
|
28
|
+
it "should return nil for no input" do
|
29
|
+
subject.package.should == nil
|
30
|
+
end
|
31
|
+
it "should return the correct default when no value is stored" do
|
32
|
+
subject.renders.should == "a default response"
|
33
|
+
subject.format.should == "json"
|
34
|
+
end
|
35
|
+
it "should return the value when called without args" do
|
36
|
+
[:package, :renders, :format].each {|method_name|
|
37
|
+
subject.send(method_name, "hello").send(method_name).should == "hello"
|
62
38
|
}
|
63
39
|
end
|
64
|
-
it "should
|
65
|
-
|
66
|
-
|
67
|
-
value.renders &input
|
68
|
-
value.renders.should == expected
|
40
|
+
it "should return the result of callable items" do
|
41
|
+
[:package, :renders, :format].each {|method_name|
|
42
|
+
subject.send(method_name, L{ "world" }).send(method_name).should == "world"
|
69
43
|
}
|
70
44
|
end
|
45
|
+
it "should replace existing values with new ones" do
|
46
|
+
subject.package "ruby-1.8"
|
47
|
+
subject.package "ruby-1.9"
|
48
|
+
subject.package.should == "ruby-1.9"
|
49
|
+
end
|
71
50
|
end
|
72
|
-
end
|
73
51
|
|
74
|
-
|
75
|
-
describe "
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
@list.records "an item", "another item"
|
92
|
-
@list.records.should == ["an item", "another item"]
|
93
|
-
end
|
94
|
-
it "should accept an array of args" do
|
95
|
-
@list.records ["an item", "another item"]
|
96
|
-
@list.records.should == ["an item", "another item"]
|
97
|
-
end
|
98
|
-
it "should return the value when called without args" do
|
99
|
-
[:records, :produces, :valid_formats].each {|method_name|
|
100
|
-
@list.send(method_name, "hello").send(method_name).should == ["hello"]
|
101
|
-
}
|
102
|
-
end
|
103
|
-
it "should return the result of callable items" do
|
104
|
-
[:records, :produces, :valid_formats].each {|method_name|
|
105
|
-
@list.send(method_name, "hello", L{ "world" }).send(method_name).should == ["hello", "world"]
|
106
|
-
}
|
107
|
-
end
|
108
|
-
it "should append new values to existing ones" do
|
109
|
-
@list.records "scores", "quips"
|
110
|
-
@list.records "tall tales"
|
111
|
-
@list.records.should == ["scores", "quips", "tall tales"]
|
52
|
+
describe "accepts_value_for input processing" do
|
53
|
+
describe "lambda input" do
|
54
|
+
it "should return the correct call's args" do
|
55
|
+
test_value_lambdas.each_pair {|input, expected|
|
56
|
+
value = AcceptsForTest.new(input)
|
57
|
+
value.package &input
|
58
|
+
value.package.should == expected
|
59
|
+
}
|
60
|
+
end
|
61
|
+
it "should ignore default whenever any lambda is specified" do
|
62
|
+
test_value_lambdas.each_pair {|input, expected|
|
63
|
+
value = AcceptsForTest.new(input)
|
64
|
+
value.renders &input
|
65
|
+
value.renders.should == expected
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
112
69
|
end
|
113
|
-
end
|
114
70
|
|
115
71
|
|
116
|
-
describe "accepts_list_for
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
72
|
+
describe "accepts_list_for" do
|
73
|
+
it "should return the empty list for no input" do
|
74
|
+
subject.records.should == []
|
75
|
+
end
|
76
|
+
it "should return the empty list for nil input" do
|
77
|
+
subject.records nil
|
78
|
+
subject.records.should == []
|
79
|
+
end
|
80
|
+
it "should return the correct default when no value is stored" do
|
81
|
+
subject.produces.should == ["a default response"]
|
82
|
+
subject.valid_formats.should == %w[html xml js json]
|
83
|
+
end
|
84
|
+
it "should accept splatted args" do
|
85
|
+
subject.records "an item", "another item"
|
86
|
+
subject.records.should == ["an item", "another item"]
|
87
|
+
end
|
88
|
+
it "should accept an array of args" do
|
89
|
+
subject.records ["an item", "another item"]
|
90
|
+
subject.records.should == ["an item", "another item"]
|
91
|
+
end
|
92
|
+
it "should return the value when called without args" do
|
93
|
+
[:records, :produces, :valid_formats].each {|method_name|
|
94
|
+
subject.send(method_name, "hello").send(method_name).should == ["hello"]
|
95
|
+
}
|
96
|
+
end
|
97
|
+
it "should return the result of callable items" do
|
98
|
+
[:records, :produces, :valid_formats].each {|method_name|
|
99
|
+
subject.send(method_name, "hello", L{ "world" }).send(method_name).should == ["hello", "world"]
|
100
|
+
}
|
101
|
+
end
|
102
|
+
it "should append new values to existing ones" do
|
103
|
+
subject.records "scores", "quips"
|
104
|
+
subject.records "tall tales"
|
105
|
+
subject.records.should == ["scores", "quips", "tall tales"]
|
106
|
+
end
|
125
107
|
end
|
126
108
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
109
|
+
|
110
|
+
describe "accepts_list_for input processing" do
|
111
|
+
describe "value input" do
|
112
|
+
test_lists.each_pair {|input, expected|
|
113
|
+
it "should return #{expected.inspect} when passed #{input.inspect}" do
|
114
|
+
list = AcceptsForTest.new
|
115
|
+
list.records input
|
116
|
+
list.records.should == expected
|
117
|
+
end
|
133
118
|
}
|
134
119
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
120
|
+
|
121
|
+
describe "lambda input" do
|
122
|
+
it "should return the correct call's args" do
|
123
|
+
test_list_lambdas.each_pair {|input, expected|
|
124
|
+
list = AcceptsForTest.new(input)
|
125
|
+
list.records &input
|
126
|
+
list.records.should == expected
|
127
|
+
}
|
128
|
+
end
|
129
|
+
it "should ignore default whenever any lambda is specified" do
|
130
|
+
test_list_lambdas.each_pair {|input, expected|
|
131
|
+
list = AcceptsForTest.new(input)
|
132
|
+
list.produces &input
|
133
|
+
list.produces.should == expected
|
134
|
+
}
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "lambda and value input" do
|
139
|
+
test_lists.each_pair {|input, expected|
|
140
|
+
it "should return #{expected.inspect} when passed #{input.inspect} within a lambda" do
|
141
|
+
l = L{
|
142
|
+
via :brew, input
|
143
|
+
}
|
144
|
+
list = AcceptsForTest.new
|
145
|
+
list.records &l
|
146
|
+
list.records.should == expected
|
147
|
+
end
|
140
148
|
}
|
141
149
|
end
|
142
|
-
end
|
143
150
|
|
144
|
-
|
145
|
-
|
146
|
-
it "should return #{expected.inspect} when passed #{input.inspect} within a lambda" do
|
151
|
+
describe "nested lambdas" do
|
152
|
+
it "should choose recursively" do
|
147
153
|
l = L{
|
148
|
-
via :
|
154
|
+
via :brew do
|
155
|
+
via :brew, "haha, excellent"
|
156
|
+
via :apt, ":|"
|
157
|
+
end
|
158
|
+
via :apt do
|
159
|
+
via :brew, "no, not this one"
|
160
|
+
via :apt, "OK this one is just completely wrong"
|
161
|
+
end
|
149
162
|
}
|
150
163
|
list = AcceptsForTest.new
|
151
164
|
list.records &l
|
152
|
-
list.records.should ==
|
165
|
+
list.records.should == ["haha, excellent"]
|
153
166
|
end
|
154
|
-
}
|
155
|
-
end
|
156
|
-
|
157
|
-
describe "nested lambdas" do
|
158
|
-
it "should choose recursively" do
|
159
|
-
l = L{
|
160
|
-
via :macports do
|
161
|
-
via :macports, "haha, excellent"
|
162
|
-
via :apt, ":|"
|
163
|
-
end
|
164
|
-
via :apt do
|
165
|
-
via :macports, "no, not this one"
|
166
|
-
via :apt, "OK this one is just completely wrong"
|
167
|
-
end
|
168
|
-
}
|
169
|
-
list = AcceptsForTest.new
|
170
|
-
list.records &l
|
171
|
-
list.records.should == ["haha, excellent"]
|
172
167
|
end
|
173
168
|
end
|
174
169
|
end
|