Several fixes to specs (#827)

This commit is contained in:
Daniel Azuma 2019-09-11 14:08:27 -07:00 committed by GitHub
parent ab9f8f3c01
commit b03725cc4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -39,7 +39,7 @@ RSpec.describe Google::Apis::Core::BaseService do
it 'should include os version in user agent' do it 'should include os version in user agent' do
agent = service.send(:user_agent) agent = service.send(:user_agent)
expect(agent).to match /#{Google::Apis::OS_VERSION}/ expect(agent).to match Regexp.new(Regexp.escape(Google::Apis::OS_VERSION))
end end
it 'should inherit authorization' do it 'should inherit authorization' do
@ -267,6 +267,7 @@ EOF
end end
it 'should send nested multipart' do it 'should send nested multipart' do
Google::Apis::RequestOptions.default.authorization = 'a token'
service.batch_upload do |service| service.batch_upload do |service|
command = service.send(:make_upload_command, :post, 'zoo/animals', {}) command = service.send(:make_upload_command, :post, 'zoo/animals', {})
command.upload_source = StringIO.new('test') command.upload_source = StringIO.new('test')
@ -276,16 +277,16 @@ EOF
expected_body = <<EOF.gsub(/\n/, "\r\n") expected_body = <<EOF.gsub(/\n/, "\r\n")
--outer --outer
Content-Type: application/http Content-Type: application/http
Content-Id: <b1981e17-f622-49af-b2eb-203308b1b17d+0> Content-Id: <b1981e17-f622-49af-b2eb-203308b1b17d\\+0>
Content-Length: 380 Content-Length: \\d+
Content-Transfer-Encoding: binary Content-Transfer-Encoding: binary
POST /upload/zoo/animals? HTTP/1.1 POST /upload/zoo/animals\\? HTTP/1\\.1
X-Goog-Api-Client: #{x_goog_api_client_value} X-Goog-Api-Client: #{Regexp.escape(x_goog_api_client_value)}
Content-Type: multipart/related; boundary=inner Content-Type: multipart/related; boundary=inner
X-Goog-Upload-Protocol: multipart X-Goog-Upload-Protocol: multipart
Authorization: Bearer a token Authorization: Bearer a token
Host: www.googleapis.com Host: www\\.googleapis\\.com
--inner --inner
Content-Type: application/json Content-Type: application/json
@ -303,7 +304,7 @@ test
--outer-- --outer--
EOF EOF
expect(a_request(:put, 'https://www.googleapis.com/upload/').with(body: expected_body)).to have_been_made expect(a_request(:put, 'https://www.googleapis.com/upload/').with(body: Regexp.new(expected_body))).to have_been_made
end end
it 'should disallow downloads in batch' do it 'should disallow downloads in batch' do