From f0de3295fcb7f26bcf9d41cc31080509f30fc0c7 Mon Sep 17 00:00:00 2001 From: Todd Derr Date: Tue, 30 Jun 2015 17:42:30 -0400 Subject: [PATCH] Fix some issues discovered by rubocop. fix failures due to: - misformatting of wrapped lines - a superflous block (and temp dir creation) due to overzealous cut & paste. --- .../get_application_default_spec.rb | 12 ++++----- spec/googleauth/service_account_spec.rb | 14 +++++----- spec/googleauth/user_refresh_spec.rb | 26 ++++++++----------- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/spec/googleauth/get_application_default_spec.rb b/spec/googleauth/get_application_default_spec.rb index 981a31b..05128c0 100644 --- a/spec/googleauth/get_application_default_spec.rb +++ b/spec/googleauth/get_application_default_spec.rb @@ -144,13 +144,11 @@ describe '#get_application_default' do it 'succeeds with system default file' do ENV.delete(@var_name) unless ENV[@var_name].nil? FakeFS do - Dir.mktmpdir do |dir| - key_path = File.join('/etc/google/auth/', CREDENTIALS_FILE_NAME) - FileUtils.mkdir_p(File.dirname(key_path)) - File.write(key_path, cred_json_text) - expect(Google::Auth.get_application_default(@scope)).to_not be_nil - File.delete(key_path) - end + key_path = File.join('/etc/google/auth/', CREDENTIALS_FILE_NAME) + FileUtils.mkdir_p(File.dirname(key_path)) + File.write(key_path, cred_json_text) + expect(Google::Auth.get_application_default(@scope)).to_not be_nil + File.delete(key_path) end end diff --git a/spec/googleauth/service_account_spec.rb b/spec/googleauth/service_account_spec.rb index 2938f0f..24f597b 100644 --- a/spec/googleauth/service_account_spec.rb +++ b/spec/googleauth/service_account_spec.rb @@ -242,19 +242,17 @@ describe Google::Auth::ServiceAccountCredentials do it 'is nil if no file exists' do FakeFS do - expect(ServiceAccountCredentials.from_system_default_path(@scope)). - to be_nil + expect(ServiceAccountCredentials.from_system_default_path(@scope)) + .to be_nil end end it 'successfully loads the file when it is present' do FakeFS do - Dir.mktmpdir do |dir| - FileUtils.mkdir_p(File.dirname(@path)) - File.write(@path, cred_json_text) - expect(@clz.from_system_default_path(@scope)).to_not be_nil - File.delete(@path) - end + FileUtils.mkdir_p(File.dirname(@path)) + File.write(@path, cred_json_text) + expect(@clz.from_system_default_path(@scope)).to_not be_nil + File.delete(@path) end end end diff --git a/spec/googleauth/user_refresh_spec.rb b/spec/googleauth/user_refresh_spec.rb index 4462a6e..394edbd 100644 --- a/spec/googleauth/user_refresh_spec.rb +++ b/spec/googleauth/user_refresh_spec.rb @@ -196,8 +196,8 @@ describe Google::Auth::UserRefreshCredentials do it 'is nil if no file exists' do FakeFS do - expect(UserRefreshCredentials.from_system_default_path(@scope)). - to be_nil + expect(UserRefreshCredentials.from_system_default_path(@scope)) + .to be_nil end end @@ -205,25 +205,21 @@ describe Google::Auth::UserRefreshCredentials do needed = %w(client_id client_secret refresh_token) needed.each do |missing| FakeFS do - Dir.mktmpdir do |dir| - FileUtils.mkdir_p(File.dirname(@path)) - File.write(@path, cred_json_text(missing)) - expect { @clz.from_system_default_path(@scope) }. - to raise_error RuntimeError - File.delete(@path) - end + FileUtils.mkdir_p(File.dirname(@path)) + File.write(@path, cred_json_text(missing)) + expect { @clz.from_system_default_path(@scope) } + .to raise_error RuntimeError + File.delete(@path) end end end it 'successfully loads the file when it is present' do FakeFS do - Dir.mktmpdir do |dir| - FileUtils.mkdir_p(File.dirname(@path)) - File.write(@path, cred_json_text) - expect(@clz.from_system_default_path(@scope)).to_not be_nil - File.delete(@path) - end + FileUtils.mkdir_p(File.dirname(@path)) + File.write(@path, cred_json_text) + expect(@clz.from_system_default_path(@scope)).to_not be_nil + File.delete(@path) end end end