Sha256: 15960691f01ff85bce3a5578c669205a14c5054be3b111d6618ca4589a48d35c

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'
require 'google/apis/urlshortener_v1'
require 'googleauth'

Urlshortener = Google::Apis::UrlshortenerV1

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

  before(:context) do
    WebMock.allow_net_connect!
    @shortener = Urlshortener::UrlshortenerService.new
    @shortener.authorization = Google::Auth.get_application_default([Urlshortener::AUTH_URLSHORTENER])
  end

  it 'should shorten URLs in a batch' do
    @urls = []
    callback = lambda { |url, err| @urls << url unless url.nil? }
    @shortener.batch do |shortener|
      shortener.insert_url(Urlshortener::Url.new(long_url: 'https://example.com/foo'), &callback)
      shortener.insert_url(Urlshortener::Url.new(long_url: 'https://example.com/bar'), &callback)
      shortener.insert_url(Urlshortener::Url.new(long_url: 'https://example.com/baz'), &callback)
    end
    puts @urls.inspect
    expect(@urls.length).to eq 3
  end

  after(:context) do
    WebMock.disable_net_connect!
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
google-api-client-0.9.pre4 spec/integration_tests/url_shortener_spec.rb
google-api-client-0.9.pre3 spec/integration_tests/url_shortener_spec.rb
google-api-client-0.9.pre2 spec/integration_tests/url_shortener_spec.rb
google-api-client-0.9.pre1 spec/integration_tests/url_shortener_spec.rb