added optional redis credential key to be set

This commit is contained in:
Michael C. Beck 2014-01-10 15:50:04 +01:00
parent 3ef99c7ebb
commit adf6d1facd
2 changed files with 18 additions and 2 deletions

View File

@ -24,8 +24,9 @@ module Google
# Initializes the RedisStore object. # Initializes the RedisStore object.
# #
# @params [Object] Redis instance # @params [Object] Redis instance
def initialize(redis) def initialize(redis, key = nil)
@redis= redis @redis= redis
@redis_credentials_key = key
end end
## ##
@ -36,7 +37,7 @@ module Google
end end
def redis_credentials_key def redis_credentials_key
"google_api_credentials" @redis_credentials_key || "google_api_credentials"
end end
## ##

View File

@ -43,6 +43,21 @@ describe Google::APIClient::RedisStore do
end end
end end
describe 'redis_credentials_key' do
context 'without given key' do
it 'should return default key' do
subject.redis_credentials_key.should == "google_api_credentials"
end
end
context 'with given key' do
let(:redis_store) { Google::APIClient::RedisStore.new('a redis instance', 'another_google_api_credentials') }
it 'should use given key' do
redis_store.redis_credentials_key.should == "another_google_api_credentials"
end
end
end
describe 'write credentials' do describe 'write credentials' do
it 'should write credentials' do it 'should write credentials' do