This PR fixes the following test failure using Ruby 3.3.0dev:
```console
$ ruby -v
ruby 3.3.0dev (2023-08-14T15:48:39Z master 52837fcec2) [x86_64-darwin22]
$ bundle exec rspec spec/faraday_spec.rb
Randomized with seed 57031
Faraday
has a version number
proxies to default_connection
uses method_missing on Faraday if there is no proxyable method (FAILED - 1)
proxies methods that exist on the default_connection
proxied methods can be accessed
Failures:
1) Faraday proxies to default_connection uses method_missing on Faraday if there is no proxyable method
Failure/Error:
expect { Faraday.this_method_does_not_exist }.to raise_error(
NoMethodError, expected_message
)
expected NoMethodError with "undefined method `this_method_does_not_exist' for Faraday:Module",
got #<NoMethodError: undefined method `this_method_does_not_exist' for module Faraday> with backtrace:
# ./lib/faraday.rb:147:in `method_missing'
# ./spec/faraday_spec.rb:27:in `block (4 levels) in <top (required)>'
# ./spec/faraday_spec.rb:27:in `block (3 levels) in <top (required)>'
# ./spec/faraday_spec.rb:27:in `block (3 levels) in <top (required)>'
```
That error message has been changed by https://github.com/ruby/ruby/commit/e7b8d32e in Ruby 3.3.0dev.
cf. https://bugs.ruby-lang.org/issues/18285
So the test error message is changed:
Ruby 3.2 or lower:
```
undefined method `this_method_does_not_exist' for Faraday:Module
```
Ruby 3.3.0dev:
```
NoMethodError: undefined method `this_method_does_not_exist' for module Faraday
```
* Fix the default_connection proxy test
The assignment to the mock connection:
`Faraday.default_connection = mock_connection`
was persisting throughout the tests.
If the random number generator is unlucky the following error occurs:
\#<Double "Connection"> was originally created in one example but has leaked into another example and can no longer be used. rspec-mocks' doubles are designed to only last for one example, and you need to create a new one in each example you wish to use it for.
This commit fixes the issue by explicitly setting the default_connection
back to nil in an "after" block after the tests have run.
Subsequent calls to `default_connection` within the test suite then
behave as previously expected irrespective of the random test ordering.