Rename Remote::Environment#{has_,}key?

This commit is contained in:
Thibault Jouan 2014-01-08 22:27:43 +00:00
parent 56ea377e31
commit 19b091a15c
4 changed files with 9 additions and 9 deletions

View File

@ -15,7 +15,7 @@ module Producer
require 'forwardable' require 'forwardable'
extend Forwardable extend Forwardable
def_delegator :@variables, :has_key? def_delegator :@variables, :key?
def initialize(variables) def initialize(variables)
@variables = variables @variables = variables

View File

@ -3,7 +3,7 @@ module Producer
module Tests module Tests
class HasEnv < Test class HasEnv < Test
def verify def verify
env.remote.environment.has_key? arguments.first.to_s.upcase env.remote.environment.key? arguments.first.to_s.upcase
end end
end end
end end

View File

@ -33,13 +33,13 @@ module Producer::Core
end end
end end
describe '#has_key?' do describe '#key?' do
let(:key) { 'SOME_KEY' } let(:key) { 'SOME_KEY' }
it 'forwards the message to @variables' do it 'forwards the message to @variables' do
expect(environment.instance_eval { @variables }) expect(environment.instance_eval { @variables })
.to receive(:has_key?).with(key) .to receive(:key?).with(key)
environment.has_key? key environment.key? key
end end
end end
end end

View File

@ -18,22 +18,22 @@ module Producer::Core
end end
it 'stringifies the queried variable name' do it 'stringifies the queried variable name' do
expect(environment).to receive(:has_key?).with(kind_of(String)) expect(environment).to receive(:key?).with(kind_of(String))
has_env.verify has_env.verify
end end
it 'upcases the queried variable name' do it 'upcases the queried variable name' do
expect(environment).to receive(:has_key?).with('SOME_VARIABLE_NAME') expect(environment).to receive(:key?).with('SOME_VARIABLE_NAME')
has_env.verify has_env.verify
end end
it 'returns true when remote environment var is defined' do it 'returns true when remote environment var is defined' do
allow(environment).to receive(:has_key?) { true } allow(environment).to receive(:key?) { true }
expect(has_env.verify).to be true expect(has_env.verify).to be true
end end
it 'returns false when remote environment var is not defined' do it 'returns false when remote environment var is not defined' do
allow(environment).to receive(:has_key?) { false } allow(environment).to receive(:key?) { false }
expect(has_env.verify).to be false expect(has_env.verify).to be false
end end
end end