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/spec/babushka/ip_spec.rb
CHANGED
@@ -8,8 +8,8 @@ describe "IP" do
|
|
8
8
|
end
|
9
9
|
it "should work for valid IPs" do
|
10
10
|
[
|
11
|
-
'10.0.1.1'
|
12
|
-
'192.168.0.1'
|
11
|
+
'10.0.1.1',
|
12
|
+
'192.168.0.1',
|
13
13
|
'174.129.110.43'
|
14
14
|
].each {|string|
|
15
15
|
IP.new(string).should be_valid
|
@@ -17,10 +17,10 @@ describe "IP" do
|
|
17
17
|
end
|
18
18
|
it "should work for invalid IPs" do
|
19
19
|
[
|
20
|
-
'10.0.1.'
|
21
|
-
'.10.0.1'
|
22
|
-
'192.168.0'
|
23
|
-
'192.168.0.c'
|
20
|
+
'10.0.1.',
|
21
|
+
'.10.0.1',
|
22
|
+
'192.168.0',
|
23
|
+
'192.168.0.c',
|
24
24
|
'174.129.110.433'
|
25
25
|
].each {|string|
|
26
26
|
IP.new(string).should_not be_valid
|
@@ -54,8 +54,8 @@ end
|
|
54
54
|
describe "IPRange" do
|
55
55
|
it "should work for valid IPs" do
|
56
56
|
[
|
57
|
-
'10.0.1.x'
|
58
|
-
'10.0.x'
|
57
|
+
'10.0.1.x',
|
58
|
+
'10.0.x',
|
59
59
|
'174.129.x.x'
|
60
60
|
].each {|string|
|
61
61
|
IPRange.new(string).should be_valid
|
@@ -63,9 +63,9 @@ describe "IPRange" do
|
|
63
63
|
end
|
64
64
|
it "should work for invalid IPs" do
|
65
65
|
[
|
66
|
-
'10.0.1.1'
|
67
|
-
'10.0.x.1'
|
68
|
-
'10.0.x.'
|
66
|
+
'10.0.1.1',
|
67
|
+
'10.0.x.1',
|
68
|
+
'10.0.x.',
|
69
69
|
'174.129.110.',
|
70
70
|
'174.129.x.43'
|
71
71
|
].each {|string|
|
@@ -12,14 +12,8 @@ describe "lambda choosing" do
|
|
12
12
|
LambdaChooser.new(nil, :ours, :theirs) {
|
13
13
|
on :ours, "this is ours"
|
14
14
|
on :theirs, "this is theirs"
|
15
|
+
"block value should be ignored"
|
15
16
|
}.choose(:ours, :on).should == ["this is ours"]
|
16
|
-
describe "with a block value" do
|
17
|
-
LambdaChooser.new(nil, :ours, :theirs) {
|
18
|
-
on :ours, "this is ours"
|
19
|
-
on :theirs, "this is theirs"
|
20
|
-
"block value"
|
21
|
-
}.choose(:ours, :on).should == ["this is ours"]
|
22
|
-
end
|
23
17
|
end
|
24
18
|
|
25
19
|
it "should pick the first choice from multiple choices" do
|
@@ -35,6 +29,30 @@ describe "lambda choosing" do
|
|
35
29
|
}.choose([:ours, :yours], :on).should == ["this is ours"]
|
36
30
|
end
|
37
31
|
|
32
|
+
context "with multiple targets" do
|
33
|
+
it "should choose the specified call" do
|
34
|
+
LambdaChooser.new(nil, :ours, :theirs, :yours) {
|
35
|
+
on :ours, "this is ours"
|
36
|
+
on [:theirs, :yours], "this is theirs or yours"
|
37
|
+
"block value should be ignored"
|
38
|
+
}.choose(:yours, :on).should == ["this is theirs or yours"]
|
39
|
+
end
|
40
|
+
it "should pick the first choice from multiple choices" do
|
41
|
+
LambdaChooser.new(nil, :ours, :yours, :theirs) {
|
42
|
+
on :ours, "this is ours"
|
43
|
+
on [:theirs, :yours], "this is theirs or yours"
|
44
|
+
}.choose([:ours, :yours], :on).should == ["this is ours"]
|
45
|
+
LambdaChooser.new(nil, :ours, :yours, :theirs) {
|
46
|
+
on :ours, "this is ours"
|
47
|
+
on [:theirs, :yours], "this is theirs or yours"
|
48
|
+
}.choose([:theirs, :ours], :on).should == ["this is theirs or yours"]
|
49
|
+
LambdaChooser.new(nil, :ours, :yours, :theirs) {
|
50
|
+
on :ours, "this is ours"
|
51
|
+
on [:theirs, :yours], "this is theirs or yours"
|
52
|
+
}.choose([:yours, :ours], :on).should == ["this is theirs or yours"]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
38
56
|
it "should reject :otherwise as a choice name" do
|
39
57
|
L{
|
40
58
|
LambdaChooser.new(nil, :ours, :yours, :otherwise)
|
@@ -59,7 +77,7 @@ describe "lambda choosing" do
|
|
59
77
|
it "should not join lists from multiple choices" do
|
60
78
|
LambdaChooser.new(
|
61
79
|
nil,
|
62
|
-
:apt, :brew, :
|
80
|
+
:apt, :brew, :yum, :linux, :osx, :ubuntu, :debian, :osx, :karmic, :gutsy, :lucid, :intrepid, :dapper, :breezy, :jaunty, :feisty, :edgy, :warty, :hardy, :maverick, :hoary, :lenny, :snow_leopard, :panther, :tiger, :leopard
|
63
81
|
) {
|
64
82
|
on :maverick, %w[ruby ruby1.8-dev]
|
65
83
|
on :apt, %w[ruby irb ruby1.8-dev libopenssl-ruby]
|
@@ -74,10 +92,20 @@ describe "lambda choosing" do
|
|
74
92
|
on :ours, "this is ours"
|
75
93
|
on :theirs, "this is theirs"
|
76
94
|
}.choose(:ours).should == ["this is ours"]
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should accept a custom choice method" do
|
98
|
+
LambdaChooser.new(nil, :ours, :theirs) {
|
99
|
+
via :ours, "this is ours"
|
100
|
+
via :theirs, "this is theirs"
|
101
|
+
}.choose(:ours, :via).should == ["this is ours"]
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should still respond to #on when a custom method is passed" do
|
77
105
|
LambdaChooser.new(nil, :ours, :theirs) {
|
78
106
|
on :ours, "this is ours"
|
79
107
|
on :theirs, "this is theirs"
|
80
|
-
}.choose(:ours,
|
108
|
+
}.choose(:ours, :via).should == ["this is ours"]
|
81
109
|
end
|
82
110
|
|
83
111
|
it "should reject values and block together" do
|
@@ -112,4 +140,14 @@ describe "lambda choosing" do
|
|
112
140
|
}.choose(:ours, :on).should == expected
|
113
141
|
}
|
114
142
|
end
|
143
|
+
|
144
|
+
it "should return DepRequirement input intact" do
|
145
|
+
LambdaChooser.new(nil, :ours, :theirs) {
|
146
|
+
on :ours, 'a dep'.with('an arg'), 'another dep'.with('another arg')
|
147
|
+
}.choose(:ours, :on).should == [
|
148
|
+
DepRequirement.new('a dep', ['an arg']),
|
149
|
+
DepRequirement.new('another dep', ['another arg'])
|
150
|
+
]
|
151
|
+
end
|
152
|
+
|
115
153
|
end
|
@@ -22,6 +22,15 @@ describe Parameter do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe '#current_value' do
|
26
|
+
it "should return the value when the parameter is set" do
|
27
|
+
Parameter.for(:value, 'a value').current_value.should == 'a value'
|
28
|
+
end
|
29
|
+
it "should return nil when the parameter is unset" do
|
30
|
+
Parameter.for(:value).current_value.should be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
describe "#==" do
|
26
35
|
it "should behave like a string when it's set" do
|
27
36
|
Parameter.new(:test, "a value").should == "a value"
|
@@ -45,6 +54,15 @@ describe Parameter do
|
|
45
54
|
end
|
46
55
|
end
|
47
56
|
|
57
|
+
describe "#to_a" do
|
58
|
+
it "should delegate to the value" do
|
59
|
+
Parameter.new(:test, %w[a value]).to_a.should == %w[a value]
|
60
|
+
end
|
61
|
+
it "should convert non-array values to arrays" do
|
62
|
+
Parameter.new(:test, 1..3).to_a.should == [1, 2, 3]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
48
66
|
describe "#to_str" do
|
49
67
|
it "should delegate to the value" do
|
50
68
|
File.exists?(Parameter.new(:path, "/bin")).should be_true
|
@@ -102,6 +120,9 @@ describe Parameter do
|
|
102
120
|
it "should take precedence over default values" do
|
103
121
|
Parameter.new(:unset).default!('default!').default('default').to_s.should == 'default!'
|
104
122
|
end
|
123
|
+
it "should not set the parameter when returned" do
|
124
|
+
Parameter.new(:unset).default!('default!').tap(&:to_s).should_not be_set
|
125
|
+
end
|
105
126
|
end
|
106
127
|
|
107
128
|
describe "asking for values" do
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PathChecker do
|
4
|
+
describe '.match_potential_versions' do
|
5
|
+
it "should extract a single version" do
|
6
|
+
PathChecker.match_potential_versions('0.13.2').should == ['0.13.2']
|
7
|
+
end
|
8
|
+
it "should extract multiple versions" do
|
9
|
+
PathChecker.match_potential_versions('0.13.2 9.1.3').should == ['0.13.2', '9.1.3']
|
10
|
+
end
|
11
|
+
it "should extract a version with a 'v' prefix" do
|
12
|
+
PathChecker.match_potential_versions('app v0.1.2').should == ['v0.1.2']
|
13
|
+
end
|
14
|
+
it "should work for babushka" do
|
15
|
+
PathChecker.match_potential_versions('0.13.2 (f177e22)').should == ['0.13.2', 'f177e22']
|
16
|
+
end
|
17
|
+
it "should work for postgres" do
|
18
|
+
PathChecker.match_potential_versions('psql (PostgreSQL) 9.1.3
|
19
|
+
contains support for command-line editing').should == ['9.1.3']
|
20
|
+
end
|
21
|
+
it "should match lots of things for ruby" do
|
22
|
+
PathChecker.match_potential_versions(
|
23
|
+
'ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]'
|
24
|
+
).should == ['1.9.3p194', '2012-04-20', '35410', 'x86_64-darwin12.0.0']
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when a dotted version is supplied" do
|
28
|
+
it "should only match against dotted potential versions" do
|
29
|
+
PathChecker.match_potential_versions(
|
30
|
+
'ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]', '1.9.3p0'
|
31
|
+
).should == ['1.9.3p194', 'x86_64-darwin12.0.0']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,23 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "cd" do
|
4
|
-
|
5
|
-
@tmp_dir = tmp_prefix
|
6
|
-
`mkdir -p '#{@tmp_dir}'`
|
7
|
-
@tmp_dir_2 = File.join(tmp_prefix, '2')
|
8
|
-
`mkdir -p '#{@tmp_dir_2}'`
|
9
|
-
|
10
|
-
@original_pwd = Dir.pwd
|
11
|
-
|
12
|
-
@nonexistent_dir = File.join(tmp_prefix, 'nonexistent')
|
13
|
-
Dir.rmdir(@nonexistent_dir) if File.directory?(@nonexistent_dir)
|
14
|
-
end
|
4
|
+
let!(:original_pwd) { Dir.pwd }
|
15
5
|
|
16
6
|
it "should yield if no dir is given" do
|
17
7
|
has_yielded = false
|
18
|
-
cd(nil) {|path|
|
8
|
+
PathHelpers.cd(nil) {|path|
|
19
9
|
path.should be_an_instance_of(Fancypath)
|
20
|
-
Dir.pwd.should ==
|
10
|
+
Dir.pwd.should == original_pwd
|
21
11
|
has_yielded = true
|
22
12
|
}
|
23
13
|
has_yielded.should be_true
|
@@ -25,78 +15,89 @@ describe "cd" do
|
|
25
15
|
|
26
16
|
it "should yield if no chdir is required" do
|
27
17
|
has_yielded = false
|
28
|
-
cd(
|
18
|
+
PathHelpers.cd(original_pwd) {|path|
|
29
19
|
path.should be_an_instance_of(Fancypath)
|
30
|
-
Dir.pwd.should ==
|
20
|
+
Dir.pwd.should == original_pwd
|
31
21
|
has_yielded = true
|
32
22
|
}
|
33
23
|
has_yielded.should be_true
|
34
24
|
end
|
35
25
|
it "should change dir for the duration of the block" do
|
36
26
|
has_yielded = false
|
37
|
-
cd(
|
38
|
-
Dir.pwd.should ==
|
27
|
+
PathHelpers.cd(tmp_prefix) {
|
28
|
+
Dir.pwd.should == tmp_prefix
|
39
29
|
has_yielded = true
|
40
30
|
}
|
41
31
|
has_yielded.should be_true
|
42
|
-
Dir.pwd.should ==
|
32
|
+
Dir.pwd.should == original_pwd
|
43
33
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
34
|
+
context "recursively" do
|
35
|
+
let(:tmp_subdir) { (tmp_prefix / '2').tap(&:mkdir) }
|
36
|
+
it "should work" do
|
37
|
+
has_yielded = false
|
38
|
+
PathHelpers.cd(tmp_prefix) {
|
39
|
+
Dir.pwd.should == tmp_prefix
|
40
|
+
PathHelpers.cd(tmp_subdir) {
|
41
|
+
Dir.pwd.should == tmp_subdir
|
42
|
+
has_yielded = true
|
43
|
+
}
|
44
|
+
Dir.pwd.should == tmp_prefix
|
49
45
|
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
it "should fail on nonexistent dirs" do
|
55
|
-
L{ cd(@nonexistent_dir) }.should raise_error(Errno::ENOENT)
|
46
|
+
has_yielded.should be_true
|
47
|
+
Dir.pwd.should == original_pwd
|
48
|
+
end
|
56
49
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
context "nonexistent dirs" do
|
51
|
+
let(:nonexistent_dir) {
|
52
|
+
(tmp_prefix / 'missing').tap(&:rm)
|
60
53
|
}
|
61
|
-
|
54
|
+
it "should fail" do
|
55
|
+
L{ PathHelpers.cd(nonexistent_dir) }.should raise_error(Errno::ENOENT)
|
56
|
+
end
|
57
|
+
context "when :create => true is specified" do
|
58
|
+
it "should create and cd" do
|
59
|
+
PathHelpers.cd(nonexistent_dir, :create => true) {
|
60
|
+
Dir.pwd.should == nonexistent_dir
|
61
|
+
}
|
62
|
+
Dir.pwd.should == original_pwd
|
63
|
+
end
|
64
|
+
after {
|
65
|
+
nonexistent_dir.rm
|
66
|
+
}
|
67
|
+
end
|
62
68
|
end
|
63
|
-
after {
|
64
|
-
Dir.rmdir(@nonexistent_dir) if File.directory?(@nonexistent_dir)
|
65
|
-
}
|
66
69
|
end
|
67
70
|
|
68
71
|
describe "in_build_dir" do
|
69
|
-
|
70
|
-
|
71
|
-
}
|
72
|
+
let!(:original_pwd) { Dir.pwd }
|
73
|
+
|
72
74
|
it "should change to the build dir with no args" do
|
73
|
-
in_build_dir {
|
75
|
+
PathHelpers.in_build_dir {
|
74
76
|
Dir.pwd.should == "~/.babushka/build".p
|
75
77
|
}
|
76
|
-
Dir.pwd.should ==
|
78
|
+
Dir.pwd.should == original_pwd
|
77
79
|
end
|
78
80
|
it "should append the supplied path when supplied" do
|
79
|
-
in_build_dir "tmp" do
|
81
|
+
PathHelpers.in_build_dir "tmp" do
|
80
82
|
Dir.pwd.should == "~/.babushka/build/tmp".p
|
81
83
|
end
|
82
|
-
Dir.pwd.should ==
|
84
|
+
Dir.pwd.should == original_pwd
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
88
|
describe "in_download_dir" do
|
87
|
-
|
88
|
-
|
89
|
-
}
|
89
|
+
let!(:original_pwd) { Dir.pwd }
|
90
|
+
|
90
91
|
it "should change to the download dir with no args" do
|
91
|
-
in_download_dir {
|
92
|
+
PathHelpers.in_download_dir {
|
92
93
|
Dir.pwd.should == "~/.babushka/downloads".p
|
93
94
|
}
|
94
|
-
Dir.pwd.should ==
|
95
|
+
Dir.pwd.should == original_pwd
|
95
96
|
end
|
96
97
|
it "should append the supplied path when supplied" do
|
97
|
-
in_download_dir "tmp" do
|
98
|
+
PathHelpers.in_download_dir "tmp" do
|
98
99
|
Dir.pwd.should == "~/.babushka/downloads/tmp".p
|
99
100
|
end
|
100
|
-
Dir.pwd.should ==
|
101
|
+
Dir.pwd.should == original_pwd
|
101
102
|
end
|
102
103
|
end
|
@@ -149,14 +149,14 @@ describe Prompt, "#get_path" do
|
|
149
149
|
describe "with nonexistent path" do
|
150
150
|
it "should fail" do
|
151
151
|
Prompt.should_receive(:log).with("path", {:newline => false})
|
152
|
-
Prompt.should_receive(:read_from_prompt).and_return((tmp_prefix / '
|
152
|
+
Prompt.should_receive(:read_from_prompt).and_return((tmp_prefix / 'missing').to_s)
|
153
153
|
Prompt.should_receive(:log).with("Doesn't exist, or not a directory. path", {:newline => false})
|
154
154
|
Prompt.should_receive(:read_from_prompt).and_return(tmp_prefix)
|
155
155
|
Prompt.get_path('path', :type => :path).should == tmp_prefix
|
156
156
|
end
|
157
157
|
it "should fail with a valid default" do
|
158
158
|
Prompt.should_receive(:log).with("path [/tmp]", {:newline => false})
|
159
|
-
Prompt.should_receive(:read_from_prompt).and_return((tmp_prefix / '
|
159
|
+
Prompt.should_receive(:read_from_prompt).and_return((tmp_prefix / 'missing').to_s)
|
160
160
|
Prompt.should_receive(:log).with("Doesn't exist, or not a directory. path [/tmp]", {:newline => false})
|
161
161
|
Prompt.should_receive(:read_from_prompt).and_return(tmp_prefix)
|
162
162
|
Prompt.get_path('path', :type => :path, :default => '/tmp').should == tmp_prefix
|
@@ -177,8 +177,8 @@ describe "'y' input" do
|
|
177
177
|
context "unintentional" do
|
178
178
|
it "should ask for the value again with a custom log message" do
|
179
179
|
Prompt.should_receive(:log).with("value", {:newline => false})
|
180
|
-
Prompt.should_receive(:read_from_prompt).and_return('
|
181
|
-
Prompt.should_receive(:log).with("Wait, do you mean the literal value '
|
180
|
+
Prompt.should_receive(:read_from_prompt).and_return('yes')
|
181
|
+
Prompt.should_receive(:log).with("Wait, do you mean the literal value 'yes' [n]", {:newline => false})
|
182
182
|
Prompt.should_receive(:read_from_prompt).and_return('n')
|
183
183
|
Prompt.should_receive(:log).with("Thought so :) Hit enter for the [default]. value", {:newline => false})
|
184
184
|
Prompt.should_receive(:read_from_prompt).and_return('value')
|
@@ -21,7 +21,7 @@ shared_examples_for 'renderable' do
|
|
21
21
|
end
|
22
22
|
context "after shitting up the file" do
|
23
23
|
before {
|
24
|
-
shell "echo lulz >> #{subject.path}"
|
24
|
+
ShellHelpers.shell "echo lulz >> #{subject.path}"
|
25
25
|
}
|
26
26
|
it "should not be clean" do
|
27
27
|
subject.should_not be_clean
|
@@ -40,18 +40,51 @@ shared_examples_for 'renderable' do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe Renderable do
|
43
|
+
subject { Renderable.new(dest_file) }
|
44
|
+
|
45
|
+
describe '#source_sha' do
|
46
|
+
context "when the result doesn't exist" do
|
47
|
+
let(:dest_file) { tmp_prefix / 'missing.conf' }
|
48
|
+
it "should raise an error" do
|
49
|
+
L{ subject.source_sha }.should raise_error(Errno::ENOENT)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
context "when the result is an empty file" do
|
53
|
+
let(:dest_file) {
|
54
|
+
(tmp_prefix / 'empty.conf').tap {|p| p.write "" }
|
55
|
+
}
|
56
|
+
it "should return nil" do
|
57
|
+
subject.source_sha.should == nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
context "when the result doesn't contain an Inkan seal" do
|
61
|
+
let(:dest_file) {
|
62
|
+
(tmp_prefix / 'empty.conf').tap {|p| p.write "Holy lols" }
|
63
|
+
}
|
64
|
+
it "should return nil" do
|
65
|
+
subject.source_sha.should == nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
context "when the result is a rendered file" do
|
69
|
+
let(:dest_file) {
|
70
|
+
(tmp_prefix / 'empty.conf').tap {|p| p.write "# Generated by babushka-0.10.5 at 2011-10-24 16:02:08 +1100, from 8af66582dbd74858c701fcdeabafca06798cafc2. 2d73ecb845d6459e6390ab6aabbac146a020c022" }
|
71
|
+
}
|
72
|
+
it "should return the correct sha" do
|
73
|
+
subject.source_sha.should == '8af66582dbd74858c701fcdeabafca06798cafc2'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
43
78
|
context "with a config file" do
|
44
79
|
let(:source_file) { "spec/renderable/example.conf.erb" }
|
45
80
|
let(:dest_file) { tmp_prefix / 'example.conf' }
|
46
81
|
let(:content) { %r{root #{tmp_prefix};} }
|
47
|
-
subject { Renderable.new(dest_file) }
|
48
82
|
it_should_behave_like 'renderable'
|
49
83
|
end
|
50
84
|
context "with an xml file" do
|
51
85
|
let(:source_file) { "spec/renderable/xml_example.conf.erb" }
|
52
86
|
let(:dest_file) { tmp_prefix / 'xml_example.conf' }
|
53
87
|
let(:content) { %r{<key>Lol</key>} }
|
54
|
-
subject { Renderable.new(dest_file) }
|
55
88
|
it_should_behave_like 'renderable'
|
56
89
|
context "custom comment" do
|
57
90
|
before { subject.render(source_file, :comment => '<!--', :comment_suffix => '-->') }
|
@@ -65,36 +98,36 @@ describe Renderable do
|
|
65
98
|
let(:source_file) { "spec/renderable/example.sh" }
|
66
99
|
let(:dest_file) { tmp_prefix / 'example.sh' }
|
67
100
|
let(:content) { %r{babushka 'benhoskings:up to date.repo'} }
|
68
|
-
subject { Renderable.new(dest_file) }
|
69
101
|
it_should_behave_like 'renderable'
|
70
102
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "binding handling" do
|
106
|
+
subject { Renderable.new(tmp_prefix / 'example.conf') }
|
107
|
+
context "when no explicit binding is passed" do
|
108
|
+
before {
|
109
|
+
subject.instance_eval {
|
110
|
+
def custom_renderable_path
|
111
|
+
"from implicit binding"
|
112
|
+
end
|
81
113
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
114
|
+
subject.render('spec/renderable/with_binding.conf.erb')
|
115
|
+
}
|
116
|
+
it "should render using the implicit binding" do
|
117
|
+
(tmp_prefix / 'example.conf').read.should =~ /from implicit binding/
|
85
118
|
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
119
|
+
end
|
120
|
+
context "when an explicit binding is passed" do
|
121
|
+
before {
|
122
|
+
dep 'renderable binding spec' do
|
123
|
+
def custom_renderable_path
|
124
|
+
"from explicit binding"
|
92
125
|
end
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
126
|
+
end.met?
|
127
|
+
subject.render('spec/renderable/with_binding.conf.erb', :context => Dep('renderable binding spec').context)
|
128
|
+
}
|
129
|
+
it "should render using the given binding" do
|
130
|
+
(tmp_prefix / 'example.conf').read.should =~ /from explicit binding/
|
98
131
|
end
|
99
132
|
end
|
100
133
|
end
|