Implement Remote#environment:

Build and return a Remote::Environment instance, with the output of
`env` command execution.
This commit is contained in:
Thibault Jouan 2013-08-18 20:04:01 +00:00
parent 513ba4eedb
commit b0ea7d876e
2 changed files with 27 additions and 0 deletions

View File

@ -31,6 +31,10 @@ module Producer
session.loop
output
end
def environment
Environment.new(execute 'env')
end
end
end
end

View File

@ -60,5 +60,28 @@ module Producer::Core
.to raise_error(RemoteCommandExecutionError)
end
end
describe '#environment', :ssh do
let(:command) { 'env' }
let(:output) { "FOO=bar\nBAZ=qux" }
before do
story_with_new_channel do |ch|
ch.sends_exec command
ch.gets_data output
end
end
it 'builds a remote environment with the result of `env` command' do
expect(Remote::Environment).to receive(:new).with(output)
remote.environment
end
it 'returns the environment' do
environment = double('environment')
allow(Remote::Environment).to receive(:new) { environment }
expect(remote.environment).to be environment
end
end
end
end