Commit 339165f
Fix Artifice.deactivate to properly restore Gem::Net::HTTP
The hardcoded Gem::Net::HTTP in Artifice.deactivate, is actually
the replaced Artifice::Net::HTTP. This doesn't restore the original
Gem::Net::HTTP.
Restore the saved original Gem::Net::HTTP in Artifice.deactivate
This issue caused the tests sometimes failed in
spec/bundler/fetcher/gem_remote_fetcher_local_ssl_server_spec.rb
using Artifice::Net::HTTP unintentionally. Because localhost is not included in
spec/support/artifice/helpers/endpoint.rb - permitted_hosts caused HTTP status 403
(response.body: "Host not permitted"). But Gem::Net::HTTP should be used in the
tests instead of Artifice::Net::HTTP. Possibly this issue happens when
Artifice.deactivate is called in other tests such as spec/commands/ssl_spec.rb.
That's why this issue sometimes happened rather than always.
```
1) Bundler::Fetcher local SSL server #connection PQC connects
Failure/Error: expect(response.code).to eq("200")
expected: #<Encoding:UTF-8> "200"
got: #<Encoding:ASCII-8BIT> "403"
(compared using ==)
# ./spec/bundler/fetcher/gem_remote_fetcher_local_ssl_server_spec.rb:49:in 'block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:164:in 'block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:164:in 'block (3 levels) in <top (required)>'
# ./spec/support/helpers.rb:414:in 'block in Spec::Helpers#with_gem_path_as'
# ./spec/support/helpers.rb:428:in 'Spec::Helpers#without_env_side_effects'
# ./spec/support/helpers.rb:409:in 'Spec::Helpers#with_gem_path_as'
# ./spec/spec_helper.rb:163:in 'block (2 levels) in <top (required)>'
# ./lib/rubygems.rb:306:in 'Kernel#load'
# ./lib/rubygems.rb:306:in 'Gem.activate_and_load_bin_path'
```
spec/commands/ssl_spec.rb
```
...
after(:each) do
...
Artifice.deactivate
...
end
...
```
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 446fddb commit 339165f
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
0 commit comments