From 3e3e84dd5e2e7acc87517c770f3f0f30fff0b43e Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Thu, 15 May 2025 06:19:38 +0700 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9C=A8=20OAuth2::OAUTH=5FDEBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_gradual.lock | 34 +++++++++++++++++----------------- lib/oauth2.rb | 5 ++++- lib/oauth2/client.rb | 2 +- spec/oauth2/client_spec.rb | 10 ++++------ spec/oauth2_spec.rb | 2 +- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 81583536..1e476f58 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -3,9 +3,9 @@ [66, 5, 20, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 2485198147], [78, 5, 74, "Style/InvertibleUnlessCondition: Prefer `if Gem.rubygems_version >= Gem::Version.new(\"2.7.0\")` over `unless Gem.rubygems_version < Gem::Version.new(\"2.7.0\")`.", 2453573257] ], - "lib/oauth2.rb:3930909031": [ - [31, 5, 21, "ThreadSafety/ClassAndModuleAttributes: Avoid mutating class and module attributes.", 622027168], - [34, 11, 7, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 651502127] + "lib/oauth2.rb:649414550": [ + [34, 5, 21, "ThreadSafety/ClassAndModuleAttributes: Avoid mutating class and module attributes.", 622027168], + [37, 11, 7, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 651502127] ], "lib/oauth2/authenticator.rb:3711266135": [ [42, 5, 113, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 734523108] @@ -41,7 +41,7 @@ [69, 15, 38, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1480816240], [79, 13, 23, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 2314399065] ], - "spec/oauth2/client_spec.rb:824695973": [ + "spec/oauth2/client_spec.rb:2242285093": [ [6, 1, 29, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/client*_spec.rb`.", 439549885], [174, 7, 492, "RSpec/NoExpectationExample: No expectation found in this example.", 1272021224], [193, 7, 592, "RSpec/NoExpectationExample: No expectation found in this example.", 3428877205], @@ -49,18 +49,18 @@ [221, 15, 20, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1276531672], [236, 15, 43, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1383956904], [251, 15, 43, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 3376202107], - [869, 5, 360, "RSpec/NoExpectationExample: No expectation found in this example.", 536201463], - [878, 5, 461, "RSpec/NoExpectationExample: No expectation found in this example.", 3392600621], - [889, 5, 340, "RSpec/NoExpectationExample: No expectation found in this example.", 244592251], - [934, 63, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785], - [979, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], - [983, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], - [991, 7, 89, "RSpec/NoExpectationExample: No expectation found in this example.", 4609419], - [1079, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], - [1083, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], - [1163, 17, 12, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 664794325], - [1188, 5, 459, "RSpec/NoExpectationExample: No expectation found in this example.", 2216851076], - [1198, 7, 450, "RSpec/NoExpectationExample: No expectation found in this example.", 2619808549] + [867, 5, 360, "RSpec/NoExpectationExample: No expectation found in this example.", 536201463], + [876, 5, 461, "RSpec/NoExpectationExample: No expectation found in this example.", 3392600621], + [887, 5, 340, "RSpec/NoExpectationExample: No expectation found in this example.", 244592251], + [932, 63, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785], + [977, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], + [981, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], + [989, 7, 89, "RSpec/NoExpectationExample: No expectation found in this example.", 4609419], + [1077, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], + [1081, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], + [1161, 17, 12, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 664794325], + [1186, 5, 459, "RSpec/NoExpectationExample: No expectation found in this example.", 2216851076], + [1196, 7, 450, "RSpec/NoExpectationExample: No expectation found in this example.", 2619808549] ], "spec/oauth2/error_spec.rb:1209122273": [ [23, 1, 28, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/error*_spec.rb`.", 3385870076], @@ -97,7 +97,7 @@ "spec/oauth2/version_spec.rb:1001406821": [ [3, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/version*_spec.rb`.", 1099517182] ], - "spec/oauth2_spec.rb:1511642301": [ + "spec/oauth2_spec.rb:438638294": [ [3, 1, 21, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2*_spec.rb`.", 3359091140], [5, 68, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785] ] diff --git a/lib/oauth2.rb b/lib/oauth2.rb index 2f950419..738071d9 100644 --- a/lib/oauth2.rb +++ b/lib/oauth2.rb @@ -25,7 +25,10 @@ # The namespace of this library module OAuth2 - DEFAULT_CONFIG = SnakyHash::SymbolKeyed.new(silence_extra_tokens_warning: false) + OAUTH_DEBUG = ENV.fetch("OAUTH_DEBUG", "false").casecmp("true").zero? + DEFAULT_CONFIG = SnakyHash::SymbolKeyed.new( + silence_extra_tokens_warning: !OAUTH_DEBUG, + ) @config = DEFAULT_CONFIG.dup class << self attr_accessor :config diff --git a/lib/oauth2/client.rb b/lib/oauth2/client.rb index c0f1f2a6..b6f5a977 100644 --- a/lib/oauth2/client.rb +++ b/lib/oauth2/client.rb @@ -449,7 +449,7 @@ def build_access_token_legacy(response, access_token_opts, extract_access_token) end def oauth_debug_logging(builder) - builder.response(:logger, options[:logger], bodies: true) if ENV["OAUTH_DEBUG"] == "true" + builder.response(:logger, options[:logger], bodies: true) if OAUTH_DEBUG end end end diff --git a/spec/oauth2/client_spec.rb b/spec/oauth2/client_spec.rb index 3918dc3b..283f2dd1 100644 --- a/spec/oauth2/client_spec.rb +++ b/spec/oauth2/client_spec.rb @@ -267,13 +267,12 @@ describe "#connection" do context "when debugging" do - include_context "with stubbed env" before do - stub_env("OAUTH_DEBUG" => debug_value) + stub_const("OAuth2::OAUTH_DEBUG", debug_value) end context "when OAUTH_DEBUG=true" do - let(:debug_value) { "true" } + let(:debug_value) { true } it "smoothly handles successive requests" do silence_all do @@ -301,7 +300,7 @@ end context "when OAUTH_DEBUG=false" do - let(:debug_value) { "false" } + let(:debug_value) { false } it "smoothly handles successive requests" do silence_all do @@ -358,10 +357,9 @@ end context "with ENV" do - include_context "with stubbed env" context "when OAUTH_DEBUG=true" do before do - stub_env("OAUTH_DEBUG" => "true") + stub_const("OAuth2::OAUTH_DEBUG", true) end it "outputs to $stdout when OAUTH_DEBUG=true" do diff --git a/spec/oauth2_spec.rb b/spec/oauth2_spec.rb index 51ed31fc..be0a220d 100644 --- a/spec/oauth2_spec.rb +++ b/spec/oauth2_spec.rb @@ -2,7 +2,7 @@ RSpec.describe OAuth2 do it "has a default config for silence_extra_tokens_warning" do - expect(described_class.config.silence_extra_tokens_warning).to eq(false) + expect(described_class.config.silence_extra_tokens_warning).to eq(true) end describe ".configure" do From f839c625a6b9b94bee09d72322b0e763a4ebaed9 Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Thu, 15 May 2025 06:58:34 +0700 Subject: [PATCH 2/5] =?UTF-8?q?=E2=9C=85=20Fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_gradual.lock | 8 ++++---- spec/oauth2/access_token_spec.rb | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 1e476f58..f70393ef 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -28,11 +28,11 @@ [130, 3, 52, "Gemspec/DependencyVersion: Dependency version specification is required.", 3163430777], [131, 3, 48, "Gemspec/DependencyVersion: Dependency version specification is required.", 425065368] ], - "spec/oauth2/access_token_spec.rb:388877639": [ + "spec/oauth2/access_token_spec.rb:536726727": [ [3, 1, 34, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/access_token*_spec.rb`.", 1972107547], - [594, 13, 25, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 770233088], - [664, 9, 101, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3022740639], - [668, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967] + [602, 13, 25, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 770233088], + [672, 9, 101, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3022740639], + [676, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967] ], "spec/oauth2/authenticator_spec.rb:853320290": [ [3, 1, 36, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/authenticator*_spec.rb`.", 819808017], diff --git a/spec/oauth2/access_token_spec.rb b/spec/oauth2/access_token_spec.rb index 30119944..53281a69 100644 --- a/spec/oauth2/access_token_spec.rb +++ b/spec/oauth2/access_token_spec.rb @@ -50,6 +50,10 @@ end end + before do + stub_const("OAuth2::OAUTH_DEBUG", true) + end + it "warns on STDERR" do msg = <<-MSG.lstrip OAuth2::AccessToken.from_hash: `hash` contained more than one 'token' key ([:access_token, :id_token]); using :access_token. @@ -89,6 +93,10 @@ end end + before do + stub_const("OAuth2::OAUTH_DEBUG", true) + end + let(:hash) do { id_token: "confusing bug here", From 0f2aa627af80ff1c3189885b6d37a370ca04624a Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Thu, 15 May 2025 07:16:22 +0700 Subject: [PATCH 3/5] =?UTF-8?q?=E2=9C=85=20Fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_gradual.lock | 5 ++--- lib/oauth2/client.rb | 2 +- spec/oauth2/access_token_spec.rb | 14 ++++++++++++-- spec/oauth2/client_spec.rb | 4 +--- spec/oauth2_spec.rb | 4 ++-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index f70393ef..b121aff3 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -97,8 +97,7 @@ "spec/oauth2/version_spec.rb:1001406821": [ [3, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/version*_spec.rb`.", 1099517182] ], - "spec/oauth2_spec.rb:438638294": [ - [3, 1, 21, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2*_spec.rb`.", 3359091140], - [5, 68, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785] + "spec/oauth2_spec.rb:245212644": [ + [3, 1, 21, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2*_spec.rb`.", 3359091140] ] } diff --git a/lib/oauth2/client.rb b/lib/oauth2/client.rb index b6f5a977..430200d0 100644 --- a/lib/oauth2/client.rb +++ b/lib/oauth2/client.rb @@ -449,7 +449,7 @@ def build_access_token_legacy(response, access_token_opts, extract_access_token) end def oauth_debug_logging(builder) - builder.response(:logger, options[:logger], bodies: true) if OAUTH_DEBUG + builder.response(:logger, options[:logger], bodies: true) if OAuth2::OAUTH_DEBUG end end end diff --git a/spec/oauth2/access_token_spec.rb b/spec/oauth2/access_token_spec.rb index 53281a69..f5233898 100644 --- a/spec/oauth2/access_token_spec.rb +++ b/spec/oauth2/access_token_spec.rb @@ -51,7 +51,12 @@ end before do - stub_const("OAuth2::OAUTH_DEBUG", true) + @original_setw = OAuth2.config.silence_extra_tokens_warning + OAuth2.config.silence_extra_tokens_warning = false + end + + after do + OAuth2.config.silence_extra_tokens_warning = @original_setw end it "warns on STDERR" do @@ -94,7 +99,12 @@ end before do - stub_const("OAuth2::OAUTH_DEBUG", true) + @original_setw = OAuth2.config.silence_extra_tokens_warning + OAuth2.config.silence_extra_tokens_warning = false + end + + after do + OAuth2.config.silence_extra_tokens_warning = @original_setw end let(:hash) do diff --git a/spec/oauth2/client_spec.rb b/spec/oauth2/client_spec.rb index 283f2dd1..b378f133 100644 --- a/spec/oauth2/client_spec.rb +++ b/spec/oauth2/client_spec.rb @@ -356,8 +356,7 @@ expect(response.headers).to eq("Content-Type" => "text/awesome") end - context "with ENV" do - context "when OAUTH_DEBUG=true" do + context "when silence_extra_tokens_warning=false" do before do stub_const("OAuth2::OAUTH_DEBUG", true) end @@ -374,7 +373,6 @@ expect(output).to include(*logs) end end - end it "posts a body" do response = subject.request(:post, "/reflect", body: "foo=bar") diff --git a/spec/oauth2_spec.rb b/spec/oauth2_spec.rb index be0a220d..c5fcdaee 100644 --- a/spec/oauth2_spec.rb +++ b/spec/oauth2_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true RSpec.describe OAuth2 do - it "has a default config for silence_extra_tokens_warning" do - expect(described_class.config.silence_extra_tokens_warning).to eq(true) + it "silence_extra_tokens_warning default is opposite of OAUTH_DEBUG" do + expect(described_class.config.silence_extra_tokens_warning).to eq(!OAuth2::OAUTH_DEBUG) end describe ".configure" do From 170ce27251c7b8eada7ccb8947d45910e6cbd8ef Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Thu, 15 May 2025 07:22:30 +0700 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=9A=A8=20lint=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_gradual.lock | 36 ++++++++++++++++++------------------ spec/oauth2/client_spec.rb | 26 +++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index b121aff3..57729a51 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -28,11 +28,11 @@ [130, 3, 52, "Gemspec/DependencyVersion: Dependency version specification is required.", 3163430777], [131, 3, 48, "Gemspec/DependencyVersion: Dependency version specification is required.", 425065368] ], - "spec/oauth2/access_token_spec.rb:536726727": [ + "spec/oauth2/access_token_spec.rb:2406469319": [ [3, 1, 34, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/access_token*_spec.rb`.", 1972107547], - [602, 13, 25, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 770233088], - [672, 9, 101, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3022740639], - [676, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967] + [612, 13, 25, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 770233088], + [682, 9, 101, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3022740639], + [686, 9, 79, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 2507338967] ], "spec/oauth2/authenticator_spec.rb:853320290": [ [3, 1, 36, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/authenticator*_spec.rb`.", 819808017], @@ -41,7 +41,7 @@ [69, 15, 38, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1480816240], [79, 13, 23, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 2314399065] ], - "spec/oauth2/client_spec.rb:2242285093": [ + "spec/oauth2/client_spec.rb:623759711": [ [6, 1, 29, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/client*_spec.rb`.", 439549885], [174, 7, 492, "RSpec/NoExpectationExample: No expectation found in this example.", 1272021224], [193, 7, 592, "RSpec/NoExpectationExample: No expectation found in this example.", 3428877205], @@ -49,18 +49,18 @@ [221, 15, 20, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1276531672], [236, 15, 43, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1383956904], [251, 15, 43, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 3376202107], - [867, 5, 360, "RSpec/NoExpectationExample: No expectation found in this example.", 536201463], - [876, 5, 461, "RSpec/NoExpectationExample: No expectation found in this example.", 3392600621], - [887, 5, 340, "RSpec/NoExpectationExample: No expectation found in this example.", 244592251], - [932, 63, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785], - [977, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], - [981, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], - [989, 7, 89, "RSpec/NoExpectationExample: No expectation found in this example.", 4609419], - [1077, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], - [1081, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], - [1161, 17, 12, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 664794325], - [1186, 5, 459, "RSpec/NoExpectationExample: No expectation found in this example.", 2216851076], - [1196, 7, 450, "RSpec/NoExpectationExample: No expectation found in this example.", 2619808549] + [865, 5, 360, "RSpec/NoExpectationExample: No expectation found in this example.", 536201463], + [874, 5, 461, "RSpec/NoExpectationExample: No expectation found in this example.", 3392600621], + [885, 5, 340, "RSpec/NoExpectationExample: No expectation found in this example.", 244592251], + [930, 63, 2, "RSpec/BeEq: Prefer `be` over `eq`.", 5860785], + [975, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], + [979, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], + [987, 7, 89, "RSpec/NoExpectationExample: No expectation found in this example.", 4609419], + [1075, 11, 99, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 3084776886], + [1079, 11, 82, "Style/ClassMethodsDefinitions: Use `class << self` to define a class method.", 1524553529], + [1159, 17, 12, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 664794325], + [1184, 5, 459, "RSpec/NoExpectationExample: No expectation found in this example.", 2216851076], + [1194, 7, 450, "RSpec/NoExpectationExample: No expectation found in this example.", 2619808549] ], "spec/oauth2/error_spec.rb:1209122273": [ [23, 1, 28, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/error*_spec.rb`.", 3385870076], @@ -97,7 +97,7 @@ "spec/oauth2/version_spec.rb:1001406821": [ [3, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/version*_spec.rb`.", 1099517182] ], - "spec/oauth2_spec.rb:245212644": [ + "spec/oauth2_spec.rb:1758355750": [ [3, 1, 21, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2*_spec.rb`.", 3359091140] ] } diff --git a/spec/oauth2/client_spec.rb b/spec/oauth2/client_spec.rb index b378f133..59d6a71b 100644 --- a/spec/oauth2/client_spec.rb +++ b/spec/oauth2/client_spec.rb @@ -357,22 +357,22 @@ end context "when silence_extra_tokens_warning=false" do - before do - stub_const("OAuth2::OAUTH_DEBUG", true) - end + before do + stub_const("OAuth2::OAUTH_DEBUG", true) + end - it "outputs to $stdout when OAUTH_DEBUG=true" do - output = capture(:stdout) do - subject.request(:get, "/success") - end - logs = [ - "request: GET https://api.example.com/success", - "response: Status 200", - 'response: Content-Type: "text/awesome"', - ] - expect(output).to include(*logs) + it "outputs to $stdout when OAUTH_DEBUG=true" do + output = capture(:stdout) do + subject.request(:get, "/success") end + logs = [ + "request: GET https://api.example.com/success", + "response: Status 200", + 'response: Content-Type: "text/awesome"', + ] + expect(output).to include(*logs) end + end it "posts a body" do response = subject.request(:post, "/reflect", body: "foo=bar") From 53a817aef54be5bcdc6da65e4eed8b4ee6f6349a Mon Sep 17 00:00:00 2001 From: "Peter H. Boling" Date: Thu, 15 May 2025 07:26:00 +0700 Subject: [PATCH 5/5] =?UTF-8?q?=E2=9C=85=20Fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop_gradual.lock | 4 ++-- lib/oauth2.rb | 2 +- spec/oauth2_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop_gradual.lock b/.rubocop_gradual.lock index 57729a51..dfb5f80e 100644 --- a/.rubocop_gradual.lock +++ b/.rubocop_gradual.lock @@ -3,7 +3,7 @@ [66, 5, 20, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 2485198147], [78, 5, 74, "Style/InvertibleUnlessCondition: Prefer `if Gem.rubygems_version >= Gem::Version.new(\"2.7.0\")` over `unless Gem.rubygems_version < Gem::Version.new(\"2.7.0\")`.", 2453573257] ], - "lib/oauth2.rb:649414550": [ + "lib/oauth2.rb:3563577000": [ [34, 5, 21, "ThreadSafety/ClassAndModuleAttributes: Avoid mutating class and module attributes.", 622027168], [37, 11, 7, "ThreadSafety/ClassInstanceVariable: Avoid class instance variables.", 651502127] ], @@ -97,7 +97,7 @@ "spec/oauth2/version_spec.rb:1001406821": [ [3, 1, 30, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2/version*_spec.rb`.", 1099517182] ], - "spec/oauth2_spec.rb:1758355750": [ + "spec/oauth2_spec.rb:2292862590": [ [3, 1, 21, "RSpec/SpecFilePathFormat: Spec path should end with `o_auth2*_spec.rb`.", 3359091140] ] } diff --git a/lib/oauth2.rb b/lib/oauth2.rb index 738071d9..ec88b462 100644 --- a/lib/oauth2.rb +++ b/lib/oauth2.rb @@ -27,7 +27,7 @@ module OAuth2 OAUTH_DEBUG = ENV.fetch("OAUTH_DEBUG", "false").casecmp("true").zero? DEFAULT_CONFIG = SnakyHash::SymbolKeyed.new( - silence_extra_tokens_warning: !OAUTH_DEBUG, + silence_extra_tokens_warning: true, ) @config = DEFAULT_CONFIG.dup class << self diff --git a/spec/oauth2_spec.rb b/spec/oauth2_spec.rb index c5fcdaee..09240997 100644 --- a/spec/oauth2_spec.rb +++ b/spec/oauth2_spec.rb @@ -2,7 +2,7 @@ RSpec.describe OAuth2 do it "silence_extra_tokens_warning default is opposite of OAUTH_DEBUG" do - expect(described_class.config.silence_extra_tokens_warning).to eq(!OAuth2::OAUTH_DEBUG) + expect(described_class.config.silence_extra_tokens_warning).to be(true) end describe ".configure" do