Sha256: 70603019e658b8a29d0bef87dd47d99ae3670c467304f611a565906eac29a196

Contents?: true

Size: 953 Bytes

Versions: 11

Compression:

Stored size: 953 Bytes

Contents

require 'spec_helper'
require 'google/apis/drive_v2'
require 'googleauth'
require 'fileutils'

Drive = Google::Apis::DriveV2

RSpec.describe Google::Apis::DriveV2, :if => run_integration_tests? do

  before(:context) do
    WebMock.allow_net_connect!
    @drive = Drive::DriveService.new
    @drive.authorization = Google::Auth.get_application_default([Drive::AUTH_DRIVE])
  end

  it 'should upload and download files' do
    # Insert a file
    content_path = File.join(FIXTURES_DIR, 'files', 'test_api.json')
    file = @drive.insert_file({title: 'test_file.txt'}, upload_source: content_path)
    puts "Created file #{file.title} (#{file.id})"

    # Read it back
    tmp = @drive.get_file(file.id, download_dest: Tempfile.new('drive'))

    # Delete it
    @drive.delete_file(file.id)
    puts "File deleted"

    expect(FileUtils.compare_file(content_path, tmp)).to be_truthy
  end

  after(:context) do
    WebMock.disable_net_connect!
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
google-api-client-0.9.5 spec/integration_tests/drive_spec.rb
google-api-client-0.9.4 spec/integration_tests/drive_spec.rb
google-api-client-0.9.3 spec/integration_tests/drive_spec.rb
google-api-client-0.9.2 spec/integration_tests/drive_spec.rb
google-api-client-0.9.1 spec/integration_tests/drive_spec.rb
google-api-client-0.9 spec/integration_tests/drive_spec.rb
google-api-client-0.9.pre5 spec/integration_tests/drive_spec.rb
google-api-client-0.9.pre4 spec/integration_tests/drive_spec.rb
google-api-client-0.9.pre3 spec/integration_tests/drive_spec.rb
google-api-client-0.9.pre2 spec/integration_tests/drive_spec.rb
google-api-client-0.9.pre1 spec/integration_tests/drive_spec.rb