From d8952d527bf5deb6f064298e1b9c7ab9a60b2277 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 14 Aug 2023 10:37:02 -0700 Subject: [PATCH] Minor linting with the latest Rubocop Some things the old Rubocop in Chefstyle misses. Signed-off-by: Tim Smith --- Gemfile | 2 +- kitchen-google.gemspec | 2 +- lib/kitchen/driver/gce.rb | 4 +--- lib/kitchen/driver/gce_version.rb | 4 +++- spec/kitchen/driver/gce_spec.rb | 19 ++++++++++--------- spec/spec_helper.rb | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index d0ce143..400d44b 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,8 @@ group :test do end group :debug do - gem "pry" gem "byebug" + gem "pry" end group :chefstyle do diff --git a/kitchen-google.gemspec b/kitchen-google.gemspec index c9d6731..48c42e5 100644 --- a/kitchen-google.gemspec +++ b/kitchen-google.gemspec @@ -1,4 +1,4 @@ -$:.push File.expand_path("lib", __dir__) +$LOAD_PATH.push File.expand_path("lib", __dir__) require "kitchen/driver/gce_version" Gem::Specification.new do |s| diff --git a/lib/kitchen/driver/gce.rb b/lib/kitchen/driver/gce.rb index f935331..42dbad3 100644 --- a/lib/kitchen/driver/gce.rb +++ b/lib/kitchen/driver/gce.rb @@ -554,9 +554,7 @@ def instance_guest_accelerators count = 1 - if guest_accelerator.key?(:count) - count = guest_accelerator[:count] - end + count = guest_accelerator[:count] if guest_accelerator.key?(:count) guest_accelerator_obj.accelerator_count = count diff --git a/lib/kitchen/driver/gce_version.rb b/lib/kitchen/driver/gce_version.rb index 145edf8..9bd2413 100644 --- a/lib/kitchen/driver/gce_version.rb +++ b/lib/kitchen/driver/gce_version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Author:: Chef Partner Engineering () # Copyright:: Copyright (c) Chef Software, Inc. @@ -18,6 +20,6 @@ module Kitchen module Driver - GCE_VERSION = "2.3.0".freeze + GCE_VERSION = "2.3.0" end end diff --git a/spec/kitchen/driver/gce_spec.rb b/spec/kitchen/driver/gce_spec.rb index a953393..03a979b 100644 --- a/spec/kitchen/driver/gce_spec.rb +++ b/spec/kitchen/driver/gce_spec.rb @@ -735,7 +735,6 @@ describe "#create_disks" do it "sets up a boot disk if boot is present and returns it" do - config = { disks: { disk1: { @@ -879,13 +878,12 @@ end describe "#instance_metadata" do - let(:item1 ) { double("item1") } - let(:item2 ) { double("item2") } - let(:item3 ) { double("item3") } + let(:item1) { double("item1") } + let(:item2) { double("item2") } + let(:item3) { double("item3") } let(:metadata) { double("metadata") } it "returns a properly-configured metadata object" do - expect(instance).to receive(:name).and_return("instance_name") expect(driver).to receive(:env_user).and_return("env_user") expect(Google::Apis::ComputeV1::Metadata).to receive(:new).and_return(metadata) @@ -1129,15 +1127,18 @@ it "returns an array containing a properly-formatted service account" do service_account = double("service_account") - allow(driver).to receive(:config).and_return(service_account_name: "account_name", service_account_scopes: %w{scope1 scope2}) + allow(driver).to receive(:config).and_return(service_account_name: "account_name", + service_account_scopes: %w{ + scope1 scope2 + }) expect(Google::Apis::ComputeV1::ServiceAccount).to receive(:new).and_return(service_account) expect(service_account).to receive(:email=).with("account_name") expect(driver).to receive(:service_account_scope_url).with("scope1").and_return("https://www.googleapis.com/auth/scope1") expect(driver).to receive(:service_account_scope_url).with("scope2").and_return("https://www.googleapis.com/auth/scope2") expect(service_account).to receive(:scopes=).with([ - "https://www.googleapis.com/auth/scope1", - "https://www.googleapis.com/auth/scope2", - ]) + "https://www.googleapis.com/auth/scope1", + "https://www.googleapis.com/auth/scope2", + ]) expect(driver.instance_service_accounts).to eq([service_account]) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7823b26..39dd4d7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,4 +31,4 @@ # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed -end \ No newline at end of file +end