Implement Remote#config:

Load SSH configuration for targeted host name.
This commit is contained in:
Thibault Jouan 2013-09-26 19:22:07 +00:00
parent 9985fceb63
commit 768a6755de
2 changed files with 22 additions and 0 deletions

View File

@ -14,6 +14,10 @@ module Producer
@session ||= Net::SSH.start(@hostname, user_name)
end
def config
@config ||= Net::SSH::Config.for(@hostname)
end
def user_name
Etc.getlogin
end

View File

@ -29,6 +29,24 @@ module Producer::Core
end
end
describe '#config' do
it 'builds a config for current host name' do
expect(Net::SSH::Config).to receive(:for).with(hostname)
remote.config
end
it 'returns the config' do
ssh_config = double('ssh config')
allow(Net::SSH::Config).to receive(:for) { ssh_config }
expect(remote.config).to be ssh_config
end
it 'memoizes the config' do
allow(Net::SSH::Config).to receive(:for) { Object.new }
expect(remote.config).to be remote.config
end
end
describe '#user_name' do
it 'returns the name of the user currently logged in' do
expect(remote.user_name).to eq Etc.getlogin