adds some specs for storage class
This commit is contained in:
parent
6404615a57
commit
e6858bd292
|
@ -7,10 +7,48 @@ describe Google::APIClient::Storage do
|
||||||
let(:root_path) { File.expand_path(File.join(__FILE__, '..', '..', '..')) }
|
let(:root_path) { File.expand_path(File.join(__FILE__, '..', '..', '..')) }
|
||||||
let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
|
let(:json_file) { File.expand_path(File.join(root_path, 'fixtures', 'files', 'auth_stored_credentials.json')) }
|
||||||
|
|
||||||
|
let(:store) { double }
|
||||||
|
let(:client_stub) { double }
|
||||||
|
subject { Google::APIClient::Storage.new(store) }
|
||||||
|
|
||||||
it 'should initialize'
|
it 'should initialize'
|
||||||
|
|
||||||
describe 'authorize' do
|
describe 'authorize' do
|
||||||
it 'should authorize'
|
it 'should authorize' do
|
||||||
|
subject.should respond_to(:authorization)
|
||||||
|
subject.store.should == store
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'authorize' do
|
||||||
|
describe 'with credentials' do
|
||||||
|
|
||||||
|
it 'should initialize a new OAuth Client' do
|
||||||
|
subject.should_receive(:load_credentials).and_return({:first => 'a dummy'})
|
||||||
|
client_stub.stub(:issued_at=)
|
||||||
|
client_stub.stub(:expired?).and_return(false)
|
||||||
|
Signet::OAuth2::Client.should_receive(:new).and_return(client_stub)
|
||||||
|
subject.should_not_receive(:refresh_authorization)
|
||||||
|
subject.authorize
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should refresh authorization' do
|
||||||
|
subject.should_receive(:load_credentials).and_return({:first => 'a dummy'})
|
||||||
|
client_stub.stub(:issued_at=)
|
||||||
|
client_stub.stub(:expired?).and_return(true)
|
||||||
|
Signet::OAuth2::Client.should_receive(:new).and_return(client_stub)
|
||||||
|
subject.should_receive(:refresh_authorization)
|
||||||
|
subject.authorize
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
describe 'without credentials' do
|
||||||
|
|
||||||
|
it 'should return false' do
|
||||||
|
subject.should_receive(:load_credentials).and_return({})
|
||||||
|
subject.authorize.should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,8 +64,13 @@ describe Google::APIClient::Storage do
|
||||||
|
|
||||||
describe 'refresh_authorization' do
|
describe 'refresh_authorization' do
|
||||||
|
|
||||||
it 'should call refresh and write credentials'
|
it 'should call refresh and write credentials' do
|
||||||
|
subject.should_receive(:write_credentials)
|
||||||
|
authorization_stub = double
|
||||||
|
subject.stub(:authorization).and_return(authorization_stub)
|
||||||
|
authorization_stub.should_receive(:refresh!).and_return(true)
|
||||||
|
subject.refresh_authorization
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'load_credentials' do
|
describe 'load_credentials' do
|
||||||
|
|
Loading…
Reference in New Issue