Skip to content

Commit

Permalink
now it accept port configuration in the deploy file
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelss committed Apr 9, 2012
1 parent c2cd04c commit 33ef560
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/yads/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ module Yads
class SSH

def initialize(config)
@ssh = Net::SSH.start(config[:host], config[:user], :forward_agent => config[:forward_agent])
options = { :forward_agent => config[:forward_agent] }
options[:port] = config[:port] if config[:port]

@ssh = Net::SSH.start(config[:host], config[:user], options)
end

def execute(cmd)
Expand Down
12 changes: 9 additions & 3 deletions test/yads/test_ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def test_connect
Yads::SSH.new(:host => "example.org", :user => "deploy", :forward_agent => true)
end

def test_connect_using_non_standard_port
connection_mock(nil, :port => 2222)

Yads::SSH.new(:host => "example.org", :port => 2222, :user => "deploy", :forward_agent => true)
end

def test_execute
session = mock
session.expects(:exec!).with("mkdir -p /tmp/yads")
Expand Down Expand Up @@ -40,7 +46,7 @@ def test_close

private

def connection_mock(session = nil)
Net::SSH.expects(:start).with("example.org", "deploy", :forward_agent => true).returns(session)
end
def connection_mock(session = nil, options = {})
Net::SSH.expects(:start).with("example.org", "deploy", { :forward_agent => true }.merge(options)).returns(session)
end
end

0 comments on commit 33ef560

Please sign in to comment.