Implement Remote#environment:
Build and return a Remote::Environment instance, with the output of `env` command execution.
This commit is contained in:
parent
513ba4eedb
commit
b0ea7d876e
@ -31,6 +31,10 @@ module Producer
|
|||||||
session.loop
|
session.loop
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def environment
|
||||||
|
Environment.new(execute 'env')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -60,5 +60,28 @@ module Producer::Core
|
|||||||
.to raise_error(RemoteCommandExecutionError)
|
.to raise_error(RemoteCommandExecutionError)
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user