<commit_before>require 'spec_helper'
require_relative '../../../../lib/google/api_client'
require_relative '../../../../lib/google/api_client/auth/storage'

describe Google::APIClient::Storage do
  let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') }
  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')) }

  it 'should initialize'

  describe 'authorize' do
    it 'should authorize'
  end


  describe 'write_credentials' do

    it 'should store credentials to var'

    it 'should call store to write credentials'

    it 'should not call store to write credentials'

  end

  describe 'refresh_authorization' do

    it 'should call refresh and write credentials'

  end

  describe 'load_credentials' do
    it 'should call store to load credentials'

  end

end
<commit_msg>adds some specs for storage class<commit_after>require 'spec_helper'
require_relative '../../../../lib/google/api_client'
require_relative '../../../../lib/google/api_client/auth/storage'

describe Google::APIClient::Storage do
  let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') }
  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(:store) { double }
  let(:client_stub) { double }
  subject { Google::APIClient::Storage.new(store) }

  it 'should initialize'

  describe 'authorize' do
    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


  describe 'write_credentials' do

    it 'should store credentials to var'

    it 'should call store to write credentials'

    it 'should not call store to write credentials'

  end

  describe 'refresh_authorization' do

    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

  describe 'load_credentials' do
    it 'should call store to load credentials'

  end

end

{'fraction_non_alphanumeric': 0.11958102996799534, 'fraction_numerical': 0.0005819028222286878, 'mean_word_length': 3.6522327469553453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4659056', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1020, 'n_words': 237}