From 3bffde39e2c257f8299ce97641e9152c4c344833 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Thu, 22 Mar 2018 18:29:35 +0300 Subject: [PATCH] Add Ruby 2.5 support (#648) * Fix os version detection not to include newline * Add ruby 2.4 and 2.5 to CI --- .travis.yml | 11 +++++++---- lib/google/apis/version.rb | 4 ++-- spec/google/apis/core/service_spec.rb | 5 +++++ spec/google/apis/versions_spec.rb | 25 +++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 spec/google/apis/versions_spec.rb diff --git a/.travis.yml b/.travis.yml index 66663df1e..422726e47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,13 @@ language: ruby sudo: false rvm: - - 2.3.1 - - 2.2.5 - - 2.0.0 + - 2.0 - 2.1 + - 2.2 + - 2.3 + - 2.4 + - 2.5 + - jruby - jruby-9.0.5.0 env: - RAILS_VERSION="~>4.2.0" @@ -12,7 +15,7 @@ env: matrix: exclude: - env: RAILS_VERSION="~>5.0.0" - rvm: 2.0.0 + rvm: 2.0 - env: RAILS_VERSION="~>5.0.0" rvm: 2.1 before_install: gem install bundler diff --git a/lib/google/apis/version.rb b/lib/google/apis/version.rb index 0ae0507dd..06c33efa0 100644 --- a/lib/google/apis/version.rb +++ b/lib/google/apis/version.rb @@ -21,7 +21,7 @@ module Google # @private OS_VERSION = begin if RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/ - `ver`.sub(/\s*\[Version\s*/, '/').sub(']', '').strip + `ver`.sub(/\s*\[Version\s*/, '/').sub(']', '') elsif RUBY_PLATFORM =~ /darwin/i "Mac OS X/#{`sw_vers -productVersion`}" elsif RUBY_PLATFORM == 'java' @@ -31,7 +31,7 @@ module Google "#{name}/#{version}" else `uname -sr`.sub(' ', '/') - end + end.strip rescue RUBY_PLATFORM end diff --git a/spec/google/apis/core/service_spec.rb b/spec/google/apis/core/service_spec.rb index 465fd7f4f..abb80ce28 100644 --- a/spec/google/apis/core/service_spec.rb +++ b/spec/google/apis/core/service_spec.rb @@ -36,6 +36,11 @@ RSpec.describe Google::Apis::Core::BaseService do expect(agent).to match /^test\/1.0/ end + it 'should include os version in user agent' do + agent = service.send(:user_agent) + expect(agent).to match /#{Google::Apis::OS_VERSION}/ + end + it 'should inherit authorization' do Google::Apis::RequestOptions.default.authorization = 'a token' expect(service.authorization).to eql 'a token' diff --git a/spec/google/apis/versions_spec.rb b/spec/google/apis/versions_spec.rb new file mode 100644 index 000000000..aaf030d3b --- /dev/null +++ b/spec/google/apis/versions_spec.rb @@ -0,0 +1,25 @@ +# 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/version' + +RSpec.describe Google::Apis::VERSION do + it { is_expected.to be_a(String) } + + describe Google::Apis::OS_VERSION do + it { is_expected.to be_a(String) } + it { is_expected.not_to match /\n/ } + end +end