From 17a2cbd5bd6f41386d0d3a476db958ee9995b361 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 18 Sep 2024 16:50:11 -0400 Subject: [PATCH] chore: Avoid method redefinition warnings. These are harmless but I'm trying to get my application warning free because warnings tend to point nasty bugs. ``` lib/twilio-ruby/util/configuration.rb:8: warning: method redefined; discarding old account_sid= lib/twilio-ruby/util/configuration.rb:12: warning: method redefined; discarding old auth_token= lib/twilio-ruby/util/configuration.rb:16: warning: method redefined; discarding old http_client= lib/twilio-ruby/util/configuration.rb:20: warning: method redefined; discarding old region= lib/twilio-ruby/util/configuration.rb:24: warning: method redefined; discarding old edge= lib/twilio-ruby/util/configuration.rb:28: warning: method redefined; discarding old logger= ``` There are a number of warnings left but I can't fix them because they are in generated code. Almost all of them have to do witht the `context` method: ``` lib/twilio-ruby/rest/studio/v1/flow/engagement.rb:321: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement.rb:282: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb:162: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb:143: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb:293: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb:249: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb:170: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb:150: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution.rb:367: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution.rb:328: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb:163: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb:144: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb:299: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb:255: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb:173: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb:153: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution.rb:360: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution.rb:327: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb:163: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb:144: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb:299: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb:255: warning: previous definition of context was here lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb:173: warning: method redefined; discarding old context lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb:153: warning: previous definition of context was here lib/twilio-ruby/twiml/voice_response.rb:794: warning: method redefined; discarding old initialize lib/twilio-ruby/twiml/messaging_response.rb:50: warning: previous definition of initialize was here ``` --- lib/twilio-ruby/util/configuration.rb | 2 +- .../twilio_webhook_authentication_spec.rb | 24 +++++++++---------- spec/spec_helper.rb | 2 ++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/twilio-ruby/util/configuration.rb b/lib/twilio-ruby/util/configuration.rb index 0dfa2dc0e..55373e5b9 100644 --- a/lib/twilio-ruby/util/configuration.rb +++ b/lib/twilio-ruby/util/configuration.rb @@ -3,7 +3,7 @@ module Twilio module Util class Configuration - attr_accessor :account_sid, :auth_token, :http_client, :region, :edge, :logger + attr_reader :account_sid, :auth_token, :http_client, :region, :edge, :logger def account_sid=(value) @account_sid = value diff --git a/spec/rack/twilio_webhook_authentication_spec.rb b/spec/rack/twilio_webhook_authentication_spec.rb index b71a41116..21531a464 100644 --- a/spec/rack/twilio_webhook_authentication_spec.rb +++ b/spec/rack/twilio_webhook_authentication_spec.rb @@ -38,7 +38,7 @@ expect(Twilio::Security::RequestValidator).to receive(:new).with(auth_token).and_return(request_validator) expect(request_validator).to receive(:validate).and_return(true) request = Rack::MockRequest.env_for('/voice') - status, headers, body = @middleware.call(request) + status, _headers, _body = @middleware.call(request) expect(status).to be(200) end end @@ -51,7 +51,7 @@ it 'should not intercept when the path doesn\'t match' do expect(Twilio::Security::RequestValidator).to_not receive(:validate) request = Rack::MockRequest.env_for('/sms') - status, headers, body = @middleware.call(request) + status, _headers, _body = @middleware.call(request) expect(status).to be(200) end @@ -60,7 +60,7 @@ receive(:validate).and_return(true) ) request = Rack::MockRequest.env_for('/voice') - status, headers, body = @middleware.call(request) + status, _headers, _body = @middleware.call(request) expect(status).to be(200) end @@ -69,7 +69,7 @@ receive(:validate).and_return(false) ) request = Rack::MockRequest.env_for('/voice') - status, headers, body = @middleware.call(request) + status, _headers, _body = @middleware.call(request) expect(status).to be(403) end end @@ -82,7 +82,7 @@ it 'should not intercept when the path doesn\'t match' do expect(Twilio::Security::RequestValidator).to_not receive(:validate) request = Rack::MockRequest.env_for('icesms') - status, headers, body = @middleware.call(request) + status, _headers, _body = @middleware.call(request) expect(status).to be(200) end @@ -91,7 +91,7 @@ receive(:validate).and_return(true) ) request = Rack::MockRequest.env_for('/sms') - status, headers, body = @middleware.call(request) + status, _headers, _body = @middleware.call(request) expect(status).to be(200) end @@ -100,7 +100,7 @@ receive(:validate).and_return(false) ) request = Rack::MockRequest.env_for('/sms') - status, headers, body = @middleware.call(request) + status, _headers, _body = @middleware.call(request) expect(status).to be(403) end end @@ -118,7 +118,7 @@ request['HTTP_X_TWILIO_SIGNATURE'] = '+LYlbGr/VmN84YPJQCuWs+9UA7E=' request['CONTENT_TYPE'] = 'application/json' - status, headers, body = middleware.call(request) + status, _headers, _body = middleware.call(request) expect(status).not_to be(200) end @@ -135,7 +135,7 @@ request['HTTP_X_TWILIO_SIGNATURE'] = 'zR5Oq4f6cijN5oz5bisiVuxYnTU=' request['CONTENT_TYPE'] = 'application/json' - status, headers, body = middleware.call(request) + status, _headers, _body = middleware.call(request) expect(status).to be(200) end @@ -153,7 +153,7 @@ request['CONTENT_TYPE'] = 'application/json' request['rack.input'].read - status, headers, body = middleware.call(request) + status, _headers, _body = middleware.call(request) expect(status).to be(200) end @@ -171,7 +171,7 @@ request['HTTP_X_TWILIO_SIGNATURE'] = 'foobarbaz' expect(request['CONTENT_TYPE']).to eq('application/x-www-form-urlencoded') - status, headers, body = middleware.call(request) + status, _headers, _body = middleware.call(request) expect(status).not_to be(200) end @@ -187,7 +187,7 @@ request['HTTP_X_TWILIO_SIGNATURE'] = 'TR9Skm9jiF4WVRJznU5glK5I83k=' expect(request['CONTENT_TYPE']).to eq('application/x-www-form-urlencoded') - status, headers, body = middleware.call(request) + status, _headers, _body = middleware.call(request) expect(status).to be(200) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8b295d076..a64bceee9 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +$VERBOSE = true + if RUBY_VERSION.start_with?('3.0') require 'simplecov' require 'simplecov_json_formatter'