Sha256: f908301d3ca672172fadf6541e2ed4dc6203f7dbf7464123962b32a432dcc326

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

# Copyright 2015 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'spec_helper'
require 'google/apis/options'

RSpec.describe Google::Apis::RequestOptions do
  let(:options) { Google::Apis::RequestOptions.new }

  it 'should not merge nil values' do
    options.retries = 1
    expect(options.merge(authorization: 'foo').retries).to eql 1
  end

  it 'should merge non-nil values' do
    options.retries = 1
    expect(options.merge(authorization: 'foo').authorization).to eql 'foo'
  end

  it 'should merge from options' do
    opts = Google::Apis::RequestOptions.new
    opts.authorization = 'foo'
    expect(options.merge(opts).authorization).to eql 'foo'
  end

  it 'should allow nil in merge' do
    expect(options.merge(nil)).to be_an_instance_of(Google::Apis::RequestOptions)
  end

  it 'should override default options' do
    Google::Apis::RequestOptions.default.header = 'Content-Length: 50'
    opts = Google::Apis::RequestOptions.new
    opts.header = 'Content-Length: 70'
    expect(options.merge(opts).header).to eq 'Content-Length: 70' 
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google-api-client-0.9.pre4 spec/google/apis/options_spec.rb