Skip to content

Commit

Permalink
fix: Avoid method redefinition warnings.
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
byroot committed Sep 18, 2024
1 parent 4192192 commit 4a81ead
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/twilio-ruby/util/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions spec/rack/twilio_webhook_authentication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$VERBOSE = true

if RUBY_VERSION.start_with?('3.0')
require 'simplecov'
require 'simplecov_json_formatter'
Expand Down

0 comments on commit 4a81ead

Please sign in to comment.