hobo-inviqa 0.0.7.pre.rc3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -19
- data/Guardfile +2 -2
- data/Hobofile +1 -5
- data/bin/hobo +18 -12
- data/hobo.gemspec +0 -3
- data/lib/hobo.rb +1 -8
- data/lib/hobo/cli.rb +3 -14
- data/lib/hobo/error_handlers/debug.rb +2 -5
- data/lib/hobo/error_handlers/friendly.rb +8 -8
- data/lib/hobo/errors.rb +1 -11
- data/lib/hobo/helper/shell.rb +2 -3
- data/lib/hobo/helper/vm_command.rb +14 -164
- data/lib/hobo/lib/host_check.rb +6 -20
- data/lib/hobo/lib/host_check/deps.rb +4 -22
- data/lib/hobo/lib/host_check/git.rb +17 -41
- data/lib/hobo/lib/host_check/ruby.rb +20 -30
- data/lib/hobo/lib/host_check/vagrant.rb +6 -37
- data/lib/hobo/lib/s3sync.rb +44 -22
- data/lib/hobo/lib/seed/project.rb +4 -8
- data/lib/hobo/patches/slop.rb +2 -21
- data/lib/hobo/tasks/assets.rb +15 -12
- data/lib/hobo/tasks/deps.rb +6 -40
- data/lib/hobo/tasks/host.rb +19 -0
- data/lib/hobo/tasks/tools.rb +6 -10
- data/lib/hobo/tasks/vm.rb +11 -64
- data/lib/hobo/ui.rb +10 -27
- data/lib/hobo/util.rb +2 -36
- data/lib/hobo/version.rb +2 -2
- data/spec/hobo/asset_applicator_spec.rb +2 -2
- data/spec/hobo/cli_spec.rb +24 -35
- data/spec/hobo/config/file_spec.rb +3 -1
- data/spec/hobo/error_handlers/debug_spec.rb +5 -39
- data/spec/hobo/error_handlers/friendly_spec.rb +21 -38
- data/spec/hobo/help_formatter_spec.rb +3 -3
- data/spec/hobo/helpers/file_locator_spec.rb +2 -2
- data/spec/hobo/helpers/shell_spec.rb +2 -2
- data/spec/hobo/helpers/vm_command_spec.rb +24 -36
- data/spec/hobo/lib/s3sync_spec.rb +3 -6
- data/spec/hobo/lib/seed/project_spec.rb +3 -2
- data/spec/hobo/lib/seed/replacer_spec.rb +2 -1
- data/spec/hobo/lib/seed/seed_spec.rb +3 -2
- data/spec/hobo/logging_spec.rb +2 -2
- data/spec/hobo/metadata_spec.rb +2 -2
- data/spec/hobo/null_spec.rb +2 -2
- data/spec/hobo/paths_spec.rb +2 -1
- data/spec/hobo/ui_spec.rb +20 -104
- data/spec/spec_helper.rb +0 -1
- metadata +48 -57
- checksums.yaml +0 -15
- data/.editorconfig +0 -10
- data/lib/hobo/error_handlers/exit_code_map.rb +0 -16
- data/lib/hobo/helper/http_download.rb +0 -41
- data/lib/hobo/tasks/config.rb +0 -15
- data/lib/hobo/tasks/system.rb +0 -15
- data/lib/hobo/tasks/system/completions.rb +0 -76
- data/spec/hobo/util_spec.rb +0 -75
data/lib/hobo/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Hobo
|
2
|
-
VERSION = '0.0.7
|
3
|
-
end
|
2
|
+
VERSION = '0.0.7'
|
3
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'hobo/asset_applicator'
|
2
2
|
|
3
3
|
describe Hobo::AssetApplicatorRegistry do
|
4
4
|
describe "asset_applicators accessor" do
|
@@ -28,4 +28,4 @@ describe Hobo::AssetApplicatorRegistry do
|
|
28
28
|
registry["abc"].call.should match "block"
|
29
29
|
end
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
data/spec/hobo/cli_spec.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'rake'
|
3
|
+
require 'hobo'
|
2
4
|
|
3
5
|
describe Hobo::Cli do
|
4
6
|
cli = nil
|
5
7
|
help = nil
|
6
8
|
hobofile = nil
|
7
9
|
|
8
|
-
def test_args args
|
9
|
-
args.concat(['--skip-host-checks'])
|
10
|
-
end
|
11
|
-
|
12
10
|
before do
|
13
11
|
Rake::Task.tasks.each do |task|
|
14
12
|
task.clear
|
15
13
|
end
|
16
|
-
|
17
14
|
Hobo.ui = double(Hobo::Ui).as_null_object
|
18
15
|
help = double(Hobo::HelpFormatter).as_null_object
|
19
16
|
cli = Hobo::Cli.new help: help
|
@@ -24,8 +21,6 @@ describe Hobo::Cli do
|
|
24
21
|
FakeFS.activate!
|
25
22
|
|
26
23
|
File.write('Hobofile', hobofile)
|
27
|
-
|
28
|
-
double(Hobo::Lib::HostCheck).as_null_object
|
29
24
|
end
|
30
25
|
|
31
26
|
after do
|
@@ -34,61 +29,61 @@ describe Hobo::Cli do
|
|
34
29
|
end
|
35
30
|
|
36
31
|
it "should load the hobofile if present" do
|
37
|
-
cli.start
|
32
|
+
cli.start []
|
38
33
|
Rake::Task["test:non-interactive"].should_not be nil
|
39
34
|
end
|
40
35
|
|
41
36
|
it "should load the user hobofile if present" do
|
42
37
|
FileUtils.mkdir_p(File.dirname(Hobo.user_hobofile_path))
|
43
38
|
File.write(Hobo.user_hobofile_path, "namespace :user do\ntask :user do\nend\nend")
|
44
|
-
cli.start
|
39
|
+
cli.start []
|
45
40
|
Rake::Task["user:user"].should_not be nil
|
46
41
|
end
|
47
42
|
|
48
43
|
it "should load project config if present" do
|
49
44
|
FileUtils.mkdir_p("tools/hobo/")
|
50
45
|
File.write("tools/hobo/config.yaml", YAML::dump({ :project => "project_config" }))
|
51
|
-
cli.start
|
46
|
+
cli.start []
|
52
47
|
Hobo.project_config.project.should match "project_config"
|
53
48
|
end
|
54
49
|
|
55
50
|
it "should load user config if present" do
|
56
51
|
FileUtils.mkdir_p(Hobo.config_path)
|
57
52
|
File.write(Hobo.user_config_file, YAML::dump({ :user => "user_config" }))
|
58
|
-
cli.start
|
53
|
+
cli.start []
|
59
54
|
Hobo.user_config.user.should match "user_config"
|
60
55
|
end
|
61
56
|
|
62
57
|
it "should set command map on help formatter" do
|
63
58
|
help.should_recieve('command_map=')
|
64
|
-
cli.start
|
59
|
+
cli.start ["test", "subcommand"]
|
65
60
|
end
|
66
61
|
|
67
62
|
it "should propagate description metadata" do
|
68
63
|
map = nil
|
69
64
|
allow(help).to receive("command_map=") { |i| map = i }
|
70
|
-
cli.start
|
65
|
+
cli.start []
|
71
66
|
map["test:metadata"].description.should match "description"
|
72
67
|
end
|
73
68
|
|
74
69
|
it "should propagate long description metadata" do
|
75
70
|
map = nil
|
76
71
|
allow(help).to receive("command_map=") { |i| map = i }
|
77
|
-
cli.start
|
72
|
+
cli.start []
|
78
73
|
map["test:metadata"].long_description.should match "long description"
|
79
74
|
end
|
80
75
|
|
81
76
|
it "should propagate arg list metadata" do
|
82
77
|
map = nil
|
83
78
|
allow(help).to receive("command_map=") { |i| map = i }
|
84
|
-
cli.start
|
79
|
+
cli.start []
|
85
80
|
expect(map["test:metadata"].arg_list).to eq [ :arg ]
|
86
81
|
end
|
87
82
|
|
88
83
|
it "should propagate option metadata" do
|
89
84
|
map = nil
|
90
85
|
allow(help).to receive("command_map=") { |i| map = i }
|
91
|
-
cli.start
|
86
|
+
cli.start []
|
92
87
|
map["test:metadata"].options.length.should be 2
|
93
88
|
expect(map["test:metadata"].options.map(&:short)).to eq [ 'o', 'h' ]
|
94
89
|
expect(map["test:metadata"].options.map(&:long)).to eq [ 'option', 'help' ]
|
@@ -98,67 +93,61 @@ describe Hobo::Cli do
|
|
98
93
|
it "should propagate hidden metadata" do
|
99
94
|
map = nil
|
100
95
|
allow(help).to receive("command_map=") { |i| map = i }
|
101
|
-
cli.start
|
96
|
+
cli.start []
|
102
97
|
map["test:metadata"].hidden.should be true
|
103
98
|
end
|
104
99
|
|
105
100
|
it "should set non-interactive mode in ui if --non-interactive" do
|
106
101
|
Hobo.ui.should_receive('interactive=').with(false)
|
107
|
-
cli.start(
|
102
|
+
cli.start(['--non-interactive'])
|
108
103
|
end
|
109
104
|
|
110
105
|
it "should show help if no args or opts passed" do
|
111
106
|
help.should_receive(:help)
|
112
|
-
cli.start(
|
107
|
+
cli.start([])
|
113
108
|
end
|
114
109
|
|
115
110
|
it "should show help for --help" do
|
116
111
|
help.should_receive(:help)
|
117
|
-
cli.start
|
112
|
+
cli.start ["--help"]
|
118
113
|
end
|
119
114
|
|
120
115
|
it "should execute a top level command" do
|
121
116
|
Hobo.ui.should_recieve(:info).with("top level")
|
122
|
-
cli.start
|
117
|
+
cli.start ["top-level"]
|
123
118
|
end
|
124
119
|
|
125
120
|
it "should execute a subcommand" do
|
126
121
|
Hobo.ui.should_recieve(:info).with("Subcommand test")
|
127
|
-
cli.start
|
122
|
+
cli.start ["test", "subcommand"]
|
128
123
|
end
|
129
124
|
|
130
125
|
it "should show help for a namespace" do
|
131
126
|
help.should_receive(:help).with(all: nil, target: "test")
|
132
|
-
cli.start
|
127
|
+
cli.start ["test"]
|
133
128
|
end
|
134
129
|
|
135
130
|
it "should show command help for --help" do
|
136
131
|
help.should_receive(:help).with(all: nil, target: "test:subcommand")
|
137
|
-
cli.start
|
132
|
+
cli.start ["test", "subcommand", "--help"]
|
138
133
|
end
|
139
134
|
|
140
135
|
it "should propagate --all option to help" do
|
141
136
|
help.should_receive(:help).with(all: true, target: "test")
|
142
|
-
cli.start
|
137
|
+
cli.start ["test", "--all"]
|
143
138
|
end
|
144
139
|
|
145
140
|
it "should propagate command opts to command" do
|
146
141
|
Hobo.ui.should_receive(:info).with("1234")
|
147
|
-
cli.start
|
142
|
+
cli.start ["test", "option-test", "--testing=1234"]
|
148
143
|
end
|
149
144
|
|
150
145
|
it "should propagate arguments to command" do
|
151
146
|
Hobo.ui.should_receive(:info).with("1234")
|
152
|
-
cli.start
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should propagate unparsed arguments in :_unparsed opt" do
|
156
|
-
Hobo.ui.should_receive(:info).with("ls --help")
|
157
|
-
cli.slop.unparsed = "ls --help"
|
158
|
-
cli.start test_args(["test", "unparsed", "--skip-host-checks"])
|
147
|
+
cli.start ["test", "argument-test", "1234"]
|
159
148
|
end
|
160
149
|
|
161
150
|
it "should raise an exception if not enough arguments were passed" do
|
162
|
-
expect { cli.start(
|
151
|
+
expect { cli.start(["test", "metadata"]) }.to raise_error Hobo::MissingArgumentsError
|
163
152
|
end
|
164
|
-
end
|
153
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'hobo/paths'
|
3
|
+
require 'hobo/config/file'
|
2
4
|
|
3
5
|
describe Hobo::Config::File do
|
4
6
|
before do
|
@@ -53,4 +55,4 @@ describe Hobo::Config::File do
|
|
53
55
|
expect { Hobo::Config::File.load("test.yaml") }.to raise_error(RuntimeError, "Invalid hobo configuration (test.yaml)")
|
54
56
|
end
|
55
57
|
end
|
56
|
-
end
|
58
|
+
end
|
@@ -1,44 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'hobo/error_handlers/debug'
|
2
2
|
|
3
3
|
describe Hobo::ErrorHandlers::Debug do
|
4
|
-
before do
|
5
|
-
Hobo.ui = double(Hobo::Ui.new).as_null_object
|
6
|
-
end
|
7
|
-
|
8
|
-
def faked_exception(error_template)
|
9
|
-
error = nil
|
10
|
-
begin
|
11
|
-
raise error_template
|
12
|
-
rescue Exception => error
|
13
|
-
end
|
14
|
-
|
15
|
-
return error
|
16
|
-
end
|
17
|
-
|
18
4
|
describe "handle" do
|
19
|
-
it "should
|
20
|
-
|
21
|
-
|
22
|
-
raise Exception.new('error_message')
|
23
|
-
rescue Exception => error
|
24
|
-
end
|
25
|
-
|
26
|
-
Hobo.ui.should_receive(:error).with(/\(Exception\).*error_message.*debug_spec.rb.*/m)
|
27
|
-
Hobo::ErrorHandlers::Debug.new.handle(error)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should return exit code according to exit_code_map" do
|
31
|
-
File.write("temp_log", "command output")
|
32
|
-
output = Struct.new(:path).new
|
33
|
-
output.path = "temp_log"
|
34
|
-
|
35
|
-
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Interrupt.new).should eq 1
|
36
|
-
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::ExternalCommandError.new("command", 128, output)).should eq 3
|
37
|
-
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::InvalidCommandOrOpt.new("command")).should eq 4
|
38
|
-
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::MissingArgumentsError.new("command", ["arg1"])).should eq 5
|
39
|
-
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::UserError.new("user error")).should eq 6
|
40
|
-
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::ProjectOnlyError.new).should eq 7
|
41
|
-
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Exception.new "general").should eq 128
|
5
|
+
it "should re-raise the error" do
|
6
|
+
exception = Exception.new
|
7
|
+
expect { Hobo::ErrorHandlers::Debug.new.handle(exception) }.to raise_error exception
|
42
8
|
end
|
43
9
|
end
|
44
|
-
end
|
10
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'hobo/error_handlers/friendly'
|
2
|
+
require 'hobo/ui'
|
2
3
|
|
3
4
|
describe Hobo::ErrorHandlers::Friendly do
|
4
5
|
before do
|
@@ -12,19 +13,9 @@ describe Hobo::ErrorHandlers::Friendly do
|
|
12
13
|
FakeFS.deactivate!
|
13
14
|
end
|
14
15
|
|
15
|
-
def faked_exception(error_template)
|
16
|
-
error = nil
|
17
|
-
begin
|
18
|
-
raise error_template
|
19
|
-
rescue Exception => error
|
20
|
-
end
|
21
|
-
|
22
|
-
return error
|
23
|
-
end
|
24
|
-
|
25
16
|
describe "handle" do
|
26
17
|
it "should display specialized error for Interrupt" do
|
27
|
-
error =
|
18
|
+
error = Interrupt.new
|
28
19
|
Hobo.ui.should_receive(:warning).with(/Caught Interrupt/)
|
29
20
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
30
21
|
end
|
@@ -33,9 +24,7 @@ describe Hobo::ErrorHandlers::Friendly do
|
|
33
24
|
File.write("temp_log", "command output")
|
34
25
|
output = Struct.new(:path).new
|
35
26
|
output.path = "temp_log"
|
36
|
-
|
37
|
-
error = faked_exception Hobo::ExternalCommandError.new("command", 128, output)
|
38
|
-
|
27
|
+
error = Hobo::ExternalCommandError.new("command", 128, output)
|
39
28
|
Hobo.ui.should_receive(:error).with(/The following external command appears to have failed \(exit status 128\)/)
|
40
29
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
41
30
|
end
|
@@ -44,55 +33,49 @@ describe Hobo::ErrorHandlers::Friendly do
|
|
44
33
|
File.write("temp_log", "command output")
|
45
34
|
output = Struct.new(:path).new
|
46
35
|
output.path = "temp_log"
|
47
|
-
|
48
|
-
error = faked_exception Hobo::ExternalCommandError.new("command", 128, output)
|
49
|
-
|
36
|
+
error = Hobo::ExternalCommandError.new("command", 128, output)
|
50
37
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
51
38
|
File.read(File.join(Dir.tmpdir, 'hobo_error.log')).should match "command output"
|
52
39
|
end
|
53
40
|
|
54
41
|
it "should display specialized error for invalid command or opt error" do
|
55
|
-
error =
|
42
|
+
error = Hobo::InvalidCommandOrOpt.new("command")
|
56
43
|
Hobo.ui.should_receive(:error).with(/Invalid command or option specified: 'command'/)
|
57
44
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
58
45
|
end
|
59
46
|
|
60
47
|
it "should display specialized error for missing argument error" do
|
61
|
-
error =
|
48
|
+
error = Hobo::MissingArgumentsError.new("command", ["arg1"])
|
62
49
|
Hobo.ui.should_receive(:error).with(/Not enough arguments for command/)
|
63
50
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
64
51
|
end
|
65
52
|
|
66
53
|
it "should display specialized error for user error" do
|
67
|
-
error =
|
54
|
+
error = Hobo::UserError.new("user error")
|
68
55
|
Hobo.ui.should_receive(:error).with(/user error/)
|
69
56
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
70
57
|
end
|
71
58
|
|
72
59
|
it "should display generic error for other exception" do
|
73
|
-
error =
|
60
|
+
error = nil
|
61
|
+
begin
|
62
|
+
raise Exception.new("general error")
|
63
|
+
rescue Exception => error
|
64
|
+
end
|
65
|
+
|
74
66
|
Hobo.ui.should_receive(:error).with(/An unexpected error has occured/)
|
75
67
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
76
68
|
end
|
77
69
|
|
78
70
|
it "should write error backtrace to /tmp/hobo_error.log for other exception" do
|
79
|
-
error =
|
71
|
+
error = nil
|
72
|
+
begin
|
73
|
+
raise Exception.new("general error")
|
74
|
+
rescue Exception => error
|
75
|
+
end
|
76
|
+
|
80
77
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
81
78
|
File.read(File.join(Dir.tmpdir, 'hobo_error.log')).should match /\(Exception\) general error/
|
82
79
|
end
|
83
|
-
|
84
|
-
it "should return exit code according to exit_code_map" do
|
85
|
-
File.write("temp_log", "command output")
|
86
|
-
output = Struct.new(:path).new
|
87
|
-
output.path = "temp_log"
|
88
|
-
|
89
|
-
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Interrupt.new).should eq 1
|
90
|
-
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::ExternalCommandError.new("command", 128, output)).should eq 3
|
91
|
-
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::InvalidCommandOrOpt.new("command")).should eq 4
|
92
|
-
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::MissingArgumentsError.new("command", ["arg1"])).should eq 5
|
93
|
-
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::UserError.new("user error")).should eq 6
|
94
|
-
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::ProjectOnlyError.new).should eq 7
|
95
|
-
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Exception.new "general").should eq 128
|
96
|
-
end
|
97
80
|
end
|
98
|
-
end
|
81
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'hobo/help_formatter'
|
2
2
|
|
3
3
|
describe Hobo::HelpFormatter do
|
4
4
|
help = nil
|
@@ -38,8 +38,8 @@ describe Hobo::HelpFormatter do
|
|
38
38
|
|
39
39
|
help = Hobo::HelpFormatter.new slop
|
40
40
|
help.command_map = map
|
41
|
+
HighLine.use_color = false
|
41
42
|
Hobo.ui = Hobo::Ui.new
|
42
|
-
Hobo.ui.use_color false
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "help" do
|
@@ -160,4 +160,4 @@ describe Hobo::HelpFormatter do
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
163
|
-
end
|
163
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'hobo/helper/file_locator'
|
2
2
|
|
3
3
|
describe Hobo::Helper do
|
4
4
|
describe "locate" do
|
@@ -8,4 +8,4 @@ describe Hobo::Helper do
|
|
8
8
|
it "should chdir to file path before yielding"
|
9
9
|
it "should yield once for each matching file"
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'hobo/helper/shell'
|
2
2
|
|
3
3
|
describe Hobo::Helper do
|
4
4
|
describe "bundle_shell" do
|
@@ -18,4 +18,4 @@ describe Hobo::Helper do
|
|
18
18
|
it "should colour stderr output with red"
|
19
19
|
it "should set ENV args for command if specified with :env"
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -1,4 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'hobo/config'
|
2
|
+
require 'hobo/logging'
|
3
|
+
require 'hobo/ui'
|
4
|
+
require 'hobo/patches/deepstruct'
|
5
|
+
require 'hobo/helper/vm_command'
|
6
|
+
|
2
7
|
|
3
8
|
describe Hobo::Helper do
|
4
9
|
before do
|
@@ -7,46 +12,29 @@ describe Hobo::Helper do
|
|
7
12
|
:mysql => {
|
8
13
|
:username => "test_user",
|
9
14
|
:password => "test_pass"
|
10
|
-
},
|
11
|
-
:vm => {
|
12
|
-
:project_mount_path => '/'
|
13
15
|
}
|
14
16
|
})
|
15
|
-
|
16
|
-
Hobo.ui = Hobo::Ui.new
|
17
|
-
|
18
|
-
vmi_double = double(Hobo::Helper::VmInspector).as_null_object
|
19
|
-
vmi_double.should_receive(:ssh_config).and_return({
|
20
|
-
:ssh_host => 'fakehost',
|
21
|
-
:ssh_user => 'fakeuser',
|
22
|
-
:ssh_port => '999',
|
23
|
-
:ssh_identity => 'fakeidentity'
|
24
|
-
})
|
25
|
-
|
26
|
-
Hobo::Helper::VmCommand.class_eval do
|
27
|
-
class_variable_set '@@vm_inspector', vmi_double
|
28
|
-
end
|
29
17
|
end
|
30
18
|
|
31
19
|
describe "vm_command" do
|
32
20
|
it "should create a new vm command wrapper with specified command" do
|
33
|
-
vm_command("my_command"
|
21
|
+
vm_command("my_command").to_s.should match /-- my_command/
|
34
22
|
end
|
35
23
|
|
36
|
-
it "should default to
|
37
|
-
vm_command("my_command"
|
24
|
+
it "should default to using a psuedo tty" do
|
25
|
+
vm_command("my_command").to_s.should match /\s-t\s/
|
38
26
|
end
|
39
27
|
|
40
|
-
it "should default to
|
41
|
-
vm_command("my_command"
|
28
|
+
it "should default to vagrant user" do
|
29
|
+
vm_command("my_command").to_s.should match /vagrant@/
|
42
30
|
end
|
43
31
|
|
44
|
-
it "should default to
|
45
|
-
vm_command("my_command"
|
32
|
+
it "should default to project host name" do
|
33
|
+
vm_command("my_command").to_s.should match /@test_hostname/
|
46
34
|
end
|
47
35
|
|
48
36
|
it "should not wrap piped commands with echo by default" do
|
49
|
-
c = vm_command("my_command"
|
37
|
+
c = vm_command("my_command")
|
50
38
|
c << "test"
|
51
39
|
c.to_s.should_not match /^echo test/
|
52
40
|
end
|
@@ -54,24 +42,24 @@ describe Hobo::Helper do
|
|
54
42
|
|
55
43
|
describe "vm_mysql" do
|
56
44
|
it "should use mysql command by default" do
|
57
|
-
vm_mysql
|
45
|
+
vm_mysql.to_s.should match /-- mysql/
|
58
46
|
end
|
59
47
|
|
60
48
|
it "should use project config mysql username & password if set" do
|
61
|
-
vm_mysql
|
49
|
+
vm_mysql.to_s.should match /-- mysql.*-utest_user.*-ptest_pass/
|
62
50
|
end
|
63
51
|
|
64
|
-
it "should
|
52
|
+
it "should default to root/root if project config mysql credentials not set" do
|
65
53
|
Hobo.project_config = DeepStruct.wrap({})
|
66
|
-
vm_mysql
|
54
|
+
vm_mysql.to_s.should match /-- mysql.*-uroot.*-proot/
|
67
55
|
end
|
68
56
|
|
69
57
|
it "should allow specifying the database in options" do
|
70
|
-
vm_mysql(:
|
58
|
+
vm_mysql(:db => "test_db").to_s.should match /-- mysql.*test_db$/
|
71
59
|
end
|
72
60
|
|
73
61
|
it "should enable auto echo of piped commands" do
|
74
|
-
c = vm_mysql
|
62
|
+
c = vm_mysql
|
75
63
|
c << "SELECT 1"
|
76
64
|
c.to_s.should match /^echo SELECT\\ 1/
|
77
65
|
end
|
@@ -81,12 +69,12 @@ describe Hobo::Helper do
|
|
81
69
|
it "should execute the command using the shell helper" do
|
82
70
|
Hobo::Helper.class_eval do
|
83
71
|
alias :old_shell :shell
|
84
|
-
def shell command
|
85
|
-
command.
|
72
|
+
def shell command
|
73
|
+
command.should match /ssh.* -- my_command/
|
86
74
|
end
|
87
75
|
end
|
88
76
|
|
89
|
-
vm_shell "my_command"
|
77
|
+
vm_shell "my_command"
|
90
78
|
|
91
79
|
Hobo::Helper.class_eval do
|
92
80
|
remove_method :shell
|
@@ -94,4 +82,4 @@ describe Hobo::Helper do
|
|
94
82
|
end
|
95
83
|
end
|
96
84
|
end
|
97
|
-
end
|
85
|
+
end
|