subject.should_receive(:refresh_authorization)
subject.authorize
end
-
end
+
describe 'without credentials' do
it 'should return false' do
end
end
-
describe 'write_credentials' do
+ it 'should call store to write credentials' do
+ authorization_stub = double
+ authorization_stub.should_receive(:refresh_token).and_return(true)
+ subject.should_receive(:credentials_hash)
+ subject.store.should_receive(:write_credentials)
+ subject.write_credentials(authorization_stub)
+ subject.authorization.should == authorization_stub
+ end
- it 'should store credentials to var'
-
- it 'should call store to write credentials'
-
- it 'should not call store to write credentials'
+ it 'should not call store to write credentials' do
+ subject.should_not_receive(:credentials_hash)
+ subject.store.should_not_receive(:write_credentials)
+ expect {
+ subject.write_credentials()
+ }.not_to raise_error
+ end
+ it 'should not call store to write credentials' do
+ subject.should_not_receive(:credentials_hash)
+ subject.store.should_not_receive(:write_credentials)
+ expect {
+ subject.write_credentials('something')
+ }.not_to raise_error
+ end
end
describe 'refresh_authorization' do
-
it 'should call refresh and write credentials' do
subject.should_receive(:write_credentials)
authorization_stub = double
end
describe 'load_credentials' do
- it 'should call store to load credentials'
-
+ it 'should call store to load credentials' do
+ subject.store.should_receive(:load_credentials)
+ subject.send(:load_credentials)
+ end
end
+ describe 'credentials_hash' do
+ it 'should return an hash' do
+ authorization_stub = double
+ authorization_stub.should_receive(:access_token)
+ authorization_stub.should_receive(:client_id)
+ authorization_stub.should_receive(:client_secret)
+ authorization_stub.should_receive(:expires_in)
+ authorization_stub.should_receive(:refresh_token)
+ authorization_stub.should_receive(:issued_at).and_return('100')
+ subject.stub(:authorization).and_return(authorization_stub)
+ credentials = subject.send(:credentials_hash)
+ credentials.should include(:access_token)
+ credentials.should include(:authorization_uri)
+ credentials.should include(:client_id)
+ credentials.should include(:client_secret)
+ credentials.should include(:expires_in)
+ credentials.should include(:refresh_token)
+ credentials.should include(:token_credential_uri)
+ credentials.should include(:issued_at)
+ end
+ end
end