hobo-inviqa 0.0.7 → 0.0.8

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