Implement basic Remote::Environment class:

Represent a registry for remote environment variables, will follow an
API similar to Hash except the constructor. Currently only #has_key? is
implemented.
This commit is contained in:
Thibault Jouan
2013-08-18 20:02:53 +00:00
parent ed99c191e0
commit 513ba4eedb
3 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
require 'spec_helper'
module Producer::Core
describe Remote::Environment do
let(:variables) { { 'FOO' => 'bar', 'BAZ' => 'qux' } }
subject(:environment) { Remote::Environment.new(variables) }
describe '#initialize' do
context 'when a hash is given' do
it 'assigns the key/value pairs' do
expect(environment.instance_eval { @variables }).to eq variables
end
end
context 'when a string is given' do
subject(:environment) { Remote::Environment.new("FOO=bar\nBAZ=qux") }
it 'assigns the key/value pairs' do
expect(environment.instance_eval { @variables }).to eq variables
end
end
end
describe '#has_key?' do
let(:key) { 'SOME_KEY' }
it 'forwards the message to @variables' do
expect(environment.instance_eval { @variables })
.to receive(:has_key?).with(key)
environment.has_key? key
end
end
end
end