vagrant/test/hobo/ssh_test.rb

31 lines
1001 B
Ruby
Raw Normal View History

2010-01-26 08:01:17 +00:00
require File.join(File.dirname(__FILE__), '..', 'test_helper')
class SshTest < Test::Unit::TestCase
2010-02-01 06:23:19 +00:00
context "hobo ssh" do
2010-01-26 08:01:17 +00:00
setup do
@handler = Hobo::SSH
@script = Hobo::SSH::SCRIPT
2010-01-30 06:39:45 +00:00
Hobo.config!(hobo_mock_config)
2010-01-26 08:01:17 +00:00
end
2010-02-01 06:23:19 +00:00
2010-01-26 08:01:17 +00:00
test "should call exec with defaults when no options are supplied" do
ssh = hobo_mock_config[:ssh]
Kernel.expects(:exec).with("#{@script} #{ssh[:uname]} #{ssh[:pass]} #{ssh[:host]} #{ssh[:port]}")
2010-01-26 08:01:17 +00:00
Hobo::SSH.connect
end
test "should call exec with supplied params" do
args = {:uname => 'bar', :pass => 'baz', :host => 'bak', :port => 'bag'}
Kernel.expects(:exec).with("#{@script} #{args[:uname]} #{args[:pass]} #{args[:host]} #{args[:port]}")
2010-01-26 08:01:17 +00:00
Hobo::SSH.connect(args)
end
end
2010-02-01 06:23:19 +00:00
context "net-ssh interaction" do
should "call net::ssh.start with the proper names" do
Net::SSH.expects(:start).with("localhost", Hobo.config[:ssh][:uname], anything).once
Hobo::SSH.execute
end
end
2010-01-26 08:01:17 +00:00
end