3 require 'google/api_client'
4 require 'google/api_client/version'
7 describe Google::APIClient::RedisStore do
8 let(:root_path) { File.expand_path(File.join(__FILE__, '..', '..', '..', '..', '..')) }
9 let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
12 let(:credentials_hash) { {
13 "access_token" => "my_access_token",
14 "authorization_uri" => "https://accounts.google.com/o/oauth2/auth",
15 "client_id" => "123456_test_client_id@.apps.googleusercontent.com",
16 "client_secret" => "123456_client_secret",
18 "refresh_token" => "my_refresh_token",
19 "token_credential_uri" => "https://accounts.google.com/o/oauth2/token",
20 "issued_at" => 1384440275
23 subject { Google::APIClient::RedisStore.new('a redis instance') }
25 it 'should have a redis instance' do
26 subject.redis.should == 'a redis instance'
27 subject.redis = 'an other redis instance'
28 subject.redis.should == 'an other redis instance'
31 describe 'load_credentials' do
33 it 'should load credentials' do
35 redis.should_receive(:get).and_return(credentials_hash.to_json)
36 subject.load_credentials.should == credentials_hash
39 it 'should return nil' do
41 redis.should_receive(:get).and_return(nil)
42 subject.load_credentials.should == nil
46 describe 'write credentials' do
48 it 'should write credentials' do
50 redis.should_receive(:set).and_return('ok')
51 subject.write_credentials(credentials_hash).should be_true