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
@@ -1,23 +1,30 @@
|
|
1
1
|
class AcceptsForTest
|
2
2
|
include AcceptsListFor
|
3
3
|
include AcceptsValueFor
|
4
|
+
|
4
5
|
attr_reader :payload
|
6
|
+
|
5
7
|
def initialize name = nil
|
6
8
|
@name = name
|
7
9
|
@payload = {}
|
8
10
|
end
|
11
|
+
|
9
12
|
def chooser
|
10
|
-
:
|
13
|
+
:brew
|
11
14
|
end
|
15
|
+
|
12
16
|
def chooser_choices
|
13
|
-
[:apt, :
|
17
|
+
[:apt, :brew]
|
14
18
|
end
|
19
|
+
|
15
20
|
def default_formats
|
16
21
|
%w[html xml js json]
|
17
22
|
end
|
23
|
+
|
18
24
|
def default_format
|
19
25
|
"json"
|
20
26
|
end
|
27
|
+
|
21
28
|
accepts_value_for :package, :choose_with => :via
|
22
29
|
accepts_value_for :renders, "a default response", :choose_with => :via
|
23
30
|
accepts_value_for :format, :default_format, :choose_with => :via
|
@@ -44,11 +51,11 @@ def test_value_lambdas
|
|
44
51
|
via :apt, "git-core"
|
45
52
|
} => nil,
|
46
53
|
L{
|
47
|
-
via :
|
54
|
+
via :brew, 'ruby'
|
48
55
|
via :apt, 'git-core'
|
49
56
|
} => 'ruby',
|
50
57
|
L{
|
51
|
-
via :
|
58
|
+
via :brew, 'something else'
|
52
59
|
via :apt, 'some apt packages'
|
53
60
|
} => 'something else'
|
54
61
|
}
|
@@ -61,11 +68,11 @@ def test_list_lambdas
|
|
61
68
|
via :apt, %w[ruby irb ri rdoc]
|
62
69
|
} => [],
|
63
70
|
L{
|
64
|
-
via :
|
71
|
+
via :brew, 'ruby'
|
65
72
|
via :apt, %w[ruby irb ri rdoc]
|
66
73
|
} => ['ruby'],
|
67
74
|
L{
|
68
|
-
via :
|
75
|
+
via :brew, 'something else'
|
69
76
|
via :apt, 'some apt packages'
|
70
77
|
} => ['something else']
|
71
78
|
}
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def archive_path
|
4
|
+
__FILE__.p.parent.parent / 'archives'
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Babushka::Asset do
|
8
|
+
it "should detect file types" do
|
9
|
+
Asset.type(archive_path / 'archive.zip').should == :zip
|
10
|
+
Asset.type(archive_path / 'archive.tgz').should == :gzip
|
11
|
+
end
|
12
|
+
it "should first attempt to detect type using file extension" do
|
13
|
+
Asset.type(archive_path / 'really_a_gzip.zip').should == :zip
|
14
|
+
end
|
15
|
+
it "should attempt to detect type via `file` when there is no extension" do
|
16
|
+
Asset.should_receive(:shell).with("file '#{archive_path / 'zip_without_extension'}'").any_number_of_times.and_return('Zip archive data')
|
17
|
+
Asset.type(archive_path / 'zip_without_extension').should == :zip
|
18
|
+
end
|
19
|
+
it "should detect supported archive types" do
|
20
|
+
Asset.for(archive_path / 'archive.tgz').should be_supported
|
21
|
+
Asset.for(archive_path / 'archive.tbz2').should be_supported
|
22
|
+
end
|
23
|
+
it "should raise an error on unsupported types" do
|
24
|
+
Asset.should_receive(:shell).with("file '#{archive_path / 'invalid_archive'}'").any_number_of_times.and_return('ASCII text')
|
25
|
+
L{
|
26
|
+
Asset.for(archive_path / 'invalid_archive')
|
27
|
+
}.should raise_error("Don't know how to extract invalid_archive.")
|
28
|
+
end
|
29
|
+
it "should set the name" do
|
30
|
+
Asset.for(archive_path / 'archive.tar').name.should == 'archive'
|
31
|
+
Asset.for(archive_path / 'archive.tar.gz').name.should == 'archive'
|
32
|
+
end
|
33
|
+
it "should generate the proper command to extract the archive" do
|
34
|
+
{
|
35
|
+
'tar' => "tar -xf '#{archive_path / 'archive.tar'}'",
|
36
|
+
'tgz' => "tar -zxf '#{archive_path / 'archive.tgz'}'",
|
37
|
+
'tbz2' => "tar -jxf '#{archive_path / 'archive.tbz2'}'",
|
38
|
+
'zip' => "unzip -o '#{archive_path / 'archive.zip'}'"
|
39
|
+
}.each_pair {|ext,command|
|
40
|
+
Asset.for(archive_path / "archive.#{ext}").extract_command.should == command
|
41
|
+
}
|
42
|
+
end
|
43
|
+
it "should yield" do
|
44
|
+
yielded = false
|
45
|
+
Asset.for(archive_path / "archive.tar").extract {
|
46
|
+
yielded = true
|
47
|
+
}
|
48
|
+
yielded.should be_true
|
49
|
+
end
|
50
|
+
it "should yield in the extracted dir" do
|
51
|
+
Asset.for(archive_path / "archive.tar").extract {
|
52
|
+
Dir.pwd.should == (tmp_prefix / 'archives/archive')
|
53
|
+
}
|
54
|
+
end
|
55
|
+
it "should yield in the nested dir if there is one" do
|
56
|
+
Asset.for(archive_path / "nested_archive.tar").extract {
|
57
|
+
Dir.pwd.should == (tmp_prefix / 'archives/nested_archive/nested archive')
|
58
|
+
}
|
59
|
+
end
|
60
|
+
it "should find a standard content dir as a nested dir" do
|
61
|
+
Asset.for(archive_path / "test-0.3.1.tgz").extract {
|
62
|
+
Dir.pwd.should == (tmp_prefix / 'archives/test-0.3.1/test-0.3.1')
|
63
|
+
Dir.glob('*').should == ['content.txt']
|
64
|
+
}
|
65
|
+
end
|
66
|
+
it "shouldn't descend into some dirs" do
|
67
|
+
Asset.for(archive_path / "Blah.app.zip").extract {
|
68
|
+
Dir.pwd.should == (tmp_prefix / 'archives/Blah.app')
|
69
|
+
Dir.glob('**/*').should == ['Blah.app', 'Blah.app/content.txt']
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'cleanup' do
|
74
|
+
it "should remove the build dir on success" do
|
75
|
+
Asset.for(archive_path / "archive.tar").extract {
|
76
|
+
(tmp_prefix / 'archives/archive').exists?.should be_true
|
77
|
+
true
|
78
|
+
}
|
79
|
+
(tmp_prefix / 'archives/archive').exists?.should be_false
|
80
|
+
end
|
81
|
+
it "should not remove the build dir on failure" do
|
82
|
+
Asset.for(archive_path / "archive.tar").extract {
|
83
|
+
(tmp_prefix / 'archives/archive').exists?.should be_true
|
84
|
+
false
|
85
|
+
}
|
86
|
+
(tmp_prefix / 'archives/archive').exists?.should be_true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#content_subdir' do
|
91
|
+
let(:resource) { Asset.new('test.zip') }
|
92
|
+
|
93
|
+
context "when there is just a single file inside the archive" do
|
94
|
+
before {
|
95
|
+
Dir.stub!(:glob).and_return(['a dir'])
|
96
|
+
File.should_receive(:directory?).with('a dir').and_return(false)
|
97
|
+
}
|
98
|
+
it "should choose it, whatever it's called" do
|
99
|
+
resource.content_subdir.should be_nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
context "when there is just a single non-descendable dir inside the archive" do
|
103
|
+
before {
|
104
|
+
Dir.stub!(:glob).and_return(['a dir.app'])
|
105
|
+
File.should_receive(:directory?).with('a dir.app').and_return(true)
|
106
|
+
}
|
107
|
+
it "should choose it, whatever it's called" do
|
108
|
+
resource.content_subdir.should be_nil
|
109
|
+
end
|
110
|
+
end
|
111
|
+
context "when there is just a single dir inside the archive" do
|
112
|
+
before {
|
113
|
+
Dir.stub!(:glob).and_return(['a dir'])
|
114
|
+
File.should_receive(:directory?).with('a dir').and_return(true)
|
115
|
+
}
|
116
|
+
it "should choose it, whatever it's called" do
|
117
|
+
resource.content_subdir.should == 'a dir'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
context "when there is more than one dir" do
|
121
|
+
context "and none are named after the archive" do
|
122
|
+
before {
|
123
|
+
Dir.stub!(:glob).and_return(['contents', 'another'])
|
124
|
+
}
|
125
|
+
it "should return nil (so the original extraction dir is used)" do
|
126
|
+
resource.content_subdir.should be_nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
context "and one is named after the archive" do
|
130
|
+
before {
|
131
|
+
Dir.stub!(:glob).and_return(['contents', 'test'])
|
132
|
+
}
|
133
|
+
it "should choose the directory named after the archive" do
|
134
|
+
resource.content_subdir.should == 'test'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
context "when there are non-descendable dirs" do
|
139
|
+
context "and none are named after the archive" do
|
140
|
+
before {
|
141
|
+
Dir.stub!(:glob).and_return(['contents', 'LaunchBar.app', 'RSpec.tmbundle'])
|
142
|
+
}
|
143
|
+
it "should not choose the non-descendable dir" do
|
144
|
+
resource.content_subdir.should be_nil
|
145
|
+
end
|
146
|
+
end
|
147
|
+
context "and one is named after the archive" do
|
148
|
+
before {
|
149
|
+
Dir.stub!(:glob).and_return(['contents', 'test.app'])
|
150
|
+
}
|
151
|
+
it "should not choose the non-descendable dir" do
|
152
|
+
resource.content_subdir.should be_nil
|
153
|
+
end
|
154
|
+
end
|
155
|
+
context "one is named after the archive, and a descendable dir is present too" do
|
156
|
+
before {
|
157
|
+
Dir.stub!(:glob).and_return(['contents', 'test.app', 'test'])
|
158
|
+
}
|
159
|
+
it "should choose the descendable dir" do
|
160
|
+
resource.content_subdir.should == 'test'
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -4,7 +4,7 @@ describe "help" do
|
|
4
4
|
context "with no verb" do
|
5
5
|
before {
|
6
6
|
[
|
7
|
-
"Babushka v#{Babushka::VERSION}, (c)
|
7
|
+
"Babushka v#{Babushka::VERSION} (#{Babushka::Base.ref}), (c) 2012 Ben Hoskings <ben@hoskings.net>",
|
8
8
|
"\nThe gist:",
|
9
9
|
" #{Base.program_name} <command> [options]",
|
10
10
|
"\nAlso:",
|
@@ -22,10 +22,10 @@ describe "help" do
|
|
22
22
|
" edit Load the file containing the specified dep in $EDITOR",
|
23
23
|
"\nCommands can be abbrev'ed, as long as they remain unique.",
|
24
24
|
" e.g. '#{Base.program_name} l' is short for '#{Base.program_name} list'.",
|
25
|
-
"\n"
|
26
25
|
].each {|line|
|
27
26
|
Cmdline::Helpers.should_receive(:log).with(line)
|
28
27
|
}
|
28
|
+
Cmdline.should_receive(:log).with("\n")
|
29
29
|
}
|
30
30
|
it "should print the verb help information" do
|
31
31
|
Cmdline::Parser.for(%w[help]).run
|
@@ -34,25 +34,27 @@ describe "help" do
|
|
34
34
|
context "with a verb" do
|
35
35
|
let(:parser) { Cmdline::Parser.for(%w[help meet]) }
|
36
36
|
before {
|
37
|
-
|
38
|
-
"Babushka v#{Babushka::VERSION}, (c)
|
37
|
+
Cmdline::Helpers.should_receive(:log).with(
|
38
|
+
"Babushka v#{Babushka::VERSION} (#{Babushka::Base.ref}), (c) 2012 Ben Hoskings <ben@hoskings.net>"
|
39
|
+
)
|
40
|
+
Cmdline.should_receive(:log).with(
|
39
41
|
"\nmeet - The main one: run a dep and all its dependencies."
|
40
|
-
|
41
|
-
Cmdline::Helpers.should_receive(:log).with(line)
|
42
|
-
}
|
42
|
+
)
|
43
43
|
|
44
44
|
parser.should_receive(:log).with("
|
45
45
|
-v, --version Print the current version
|
46
46
|
-h, --help Show this information
|
47
47
|
-d, --debug Show more verbose logging, and realtime shell command output
|
48
|
+
-s, --silent Only log errors, running silently on success
|
48
49
|
--[no-]color, --[no-]colour Disable color in the output
|
49
50
|
-n, --dry-run Discover the curent state without making any changes
|
50
51
|
-y, --defaults Assume the default value for all vars without prompting, where possible
|
52
|
+
-u, --update Update referenced sources before loading deps from them
|
51
53
|
--show-args Show the arguments being passed between deps as they're run
|
52
|
-
--
|
54
|
+
--profile Print a per-line timestamp to the debug log.
|
53
55
|
")
|
54
56
|
|
55
|
-
Cmdline
|
57
|
+
Cmdline.should_receive(:log).with("\n")
|
56
58
|
}
|
57
59
|
it "should print the help information for the verb" do
|
58
60
|
parser.run
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cmdline, 'meet' do
|
4
|
+
describe "var parsing" do
|
5
|
+
before {
|
6
|
+
Base.task.should_receive(:process).with(
|
7
|
+
%w[git],
|
8
|
+
{'version' => '1.7.7', 'source' => 'http://git.org/git.tgz'}
|
9
|
+
)
|
10
|
+
}
|
11
|
+
it "should recognise vars" do
|
12
|
+
Cmdline::Parser.for(%w[git version=1.7.7 source=http://git.org/git.tgz]).run
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "version" do
|
4
4
|
before {
|
5
|
-
Cmdline::Helpers.should_receive(:log).with(Babushka::VERSION)
|
5
|
+
Cmdline::Helpers.should_receive(:log).with("#{Babushka::VERSION} (#{Babushka::Base.ref})")
|
6
6
|
}
|
7
7
|
it "should print the version" do
|
8
8
|
Cmdline::Parser.for(%w[version]).run
|
@@ -169,3 +169,12 @@ describe String, "val_for" do
|
|
169
169
|
"/dev/disk1s2 Apple_HFS /Volumes/TextMate 1.5.9".val_for(/^\/dev\/disk\d+s\d+\s+Apple_HFS\s+/).should == "/Volumes/TextMate 1.5.9"
|
170
170
|
end
|
171
171
|
end
|
172
|
+
|
173
|
+
describe String, '#colorized?' do
|
174
|
+
it "should return false for regular strings" do
|
175
|
+
"babushka".should_not be_colorized
|
176
|
+
end
|
177
|
+
it "should return true for strings containing ANSI color sequences" do
|
178
|
+
"\e[0;32;29mbabushka\e[0m".should be_colorized
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Babushka::CurrentRuby do
|
4
|
+
let(:current_ruby) { Babushka::CurrentRuby.new }
|
5
|
+
before {
|
6
|
+
current_ruby.stub!(:gem_env).and_return(%{
|
7
|
+
RubyGems Environment:
|
8
|
+
- RUBYGEMS VERSION: 1.8.23
|
9
|
+
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
|
10
|
+
- EXECUTABLE DIRECTORY: /usr/local/bin
|
11
|
+
})
|
12
|
+
}
|
13
|
+
|
14
|
+
describe '#path' do
|
15
|
+
it "should return the path to the ruby binary" do
|
16
|
+
Babushka::ShellHelpers.stub!(:which).with('ruby').and_return('/usr/local/bin/ruby')
|
17
|
+
current_ruby.path.should == '/usr/local/bin/ruby'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#rbenv?' do
|
22
|
+
it "should return true when ruby is running via rbenv" do
|
23
|
+
Babushka::ShellHelpers.stub!(:which).with('ruby').and_return('/Users/steve/.rbenv/shims/ruby')
|
24
|
+
current_ruby.rbenv?.should be_true
|
25
|
+
end
|
26
|
+
it "should return false otherwise" do
|
27
|
+
Babushka::ShellHelpers.stub!(:which).with('ruby').and_return('/usr/local/bin/ruby')
|
28
|
+
current_ruby.rbenv?.should be_false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#rvm?' do
|
33
|
+
it "should return true when ruby is running via rvm" do
|
34
|
+
Babushka::ShellHelpers.stub!(:which).with('ruby').and_return('/Users/steve/.rvm/rubies/ruby-1.9.3-p194/bin/ruby')
|
35
|
+
current_ruby.rvm?.should be_true
|
36
|
+
end
|
37
|
+
it "should return false otherwise" do
|
38
|
+
Babushka::ShellHelpers.stub!(:which).with('ruby').and_return('/usr/local/bin/ruby')
|
39
|
+
current_ruby.rvm?.should be_false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#bin_dir' do
|
44
|
+
it "should return the path containing the ruby binary" do
|
45
|
+
current_ruby.bin_dir.should == '/usr/local/bin'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#gem_dir' do
|
50
|
+
it "should return the directory containing installed gems" do
|
51
|
+
current_ruby.gem_dir.should == '/usr/local/lib/ruby/gems/1.9.1/gems'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#gemspec_dir' do
|
56
|
+
it "should return the directory containing installed gems' specs" do
|
57
|
+
current_ruby.gemspec_dir.should == '/usr/local/lib/ruby/gems/1.9.1/specifications'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#version' do
|
62
|
+
it "should return the version of the ruby installation" do
|
63
|
+
Babushka::ShellHelpers.stub!(:shell).with('ruby --version').and_return('ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]')
|
64
|
+
current_ruby.version.should == Babushka::VersionStr.new('1.9.3p194')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#gem_version' do
|
69
|
+
it "should return the version of the ruby installation's rubygems" do
|
70
|
+
current_ruby.gem_version.should == Babushka::VersionStr.new('1.8.23')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,42 +1,51 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'dep_definer_support'
|
3
2
|
|
4
3
|
describe "accepts_block_for behaviour" do
|
4
|
+
let(:lambda_hello) { L{ "hello world!" } }
|
5
|
+
|
6
|
+
def test_accepts_block_for_response accepter_name, lambda, value, opts = {}
|
7
|
+
DepContext.accepts_block_for accepter_name
|
8
|
+
dep 'accepts_block_for' do
|
9
|
+
send accepter_name, opts, &lambda
|
10
|
+
end
|
11
|
+
on = opts[:on].nil? ? :all : Babushka.host.system
|
12
|
+
Dep('accepts_block_for').context.define!.payload[accepter_name][on].should == value
|
13
|
+
end
|
14
|
+
|
5
15
|
before {
|
6
|
-
|
7
|
-
setup_test_lambdas
|
16
|
+
Babushka.host.stub!(:match_list).and_return([:osx])
|
8
17
|
dep 'default'
|
9
18
|
}
|
10
19
|
|
11
20
|
it "should define a declarer" do
|
12
21
|
Dep('default').context.should_not respond_to(:test_defining)
|
13
|
-
|
22
|
+
DepContext.accepts_block_for :test_defining
|
14
23
|
Dep('default').context.should respond_to(:test_defining)
|
15
24
|
end
|
16
25
|
|
17
26
|
it "should return lambda" do
|
18
|
-
|
27
|
+
DepContext.accepts_block_for :test_defining
|
19
28
|
lambda = L{ 'blah' }
|
20
29
|
value_from_block = nil
|
21
30
|
dep 'returning test' do
|
22
|
-
value_from_block = test_defining
|
31
|
+
value_from_block = test_defining(&lambda)
|
23
32
|
end.met?
|
24
33
|
value_from_block.should == lambda
|
25
34
|
end
|
26
35
|
|
27
36
|
it "should accept and return a block" do
|
28
|
-
test_accepts_block_for_response :test_response,
|
37
|
+
test_accepts_block_for_response :test_response, lambda_hello, lambda_hello
|
29
38
|
end
|
30
39
|
it "should accept and return a block for this system" do
|
31
|
-
test_accepts_block_for_response :test_this_system,
|
40
|
+
test_accepts_block_for_response :test_this_system, lambda_hello, lambda_hello, :on => Babushka.host.system
|
32
41
|
end
|
33
42
|
it "should return nothing on a non-specified system" do
|
34
|
-
test_accepts_block_for_response :test_other_system,
|
43
|
+
test_accepts_block_for_response :test_other_system, lambda_hello, nil, :on => :missing
|
35
44
|
end
|
36
45
|
|
37
46
|
it "should use default blocks when no specific one is specified" do
|
38
47
|
lambda = L{ 'default value' }
|
39
|
-
|
48
|
+
DepContext.accepts_block_for :test_defaults, &lambda
|
40
49
|
value_from_block = nil
|
41
50
|
dep 'default test' do
|
42
51
|
value_from_block = test_defaults
|
@@ -49,10 +58,15 @@ end
|
|
49
58
|
|
50
59
|
describe "accepts_list_for behaviour" do
|
51
60
|
before {
|
52
|
-
Babushka
|
53
|
-
|
61
|
+
Babushka.host.stub!(:match_list).and_return([:osx])
|
62
|
+
dep 'test build tools' do
|
63
|
+
requires {
|
64
|
+
on :osx, 'xcode tools'
|
65
|
+
on :linux, 'build-essential', 'autoconf'
|
66
|
+
}
|
67
|
+
end
|
54
68
|
}
|
55
69
|
it "should choose requires for the correct system" do
|
56
|
-
Dep('test build tools').context.requires.should == ['xcode tools']
|
70
|
+
Dep('test build tools').context.define!.requires.should == ['xcode tools']
|
57
71
|
end
|
58
72
|
end
|