diff options
| -rw-r--r-- | test/fixtures/does_not_follow_redirect.yml | 24 | ||||
| -rw-r--r-- | test/net/client_test.rb | 12 |
2 files changed, 36 insertions, 0 deletions
diff --git a/test/fixtures/does_not_follow_redirect.yml b/test/fixtures/does_not_follow_redirect.yml new file mode 100644 index 0000000..77e5c5a --- /dev/null +++ b/test/fixtures/does_not_follow_redirect.yml @@ -0,0 +1,24 @@ +--- +http_interactions: +- request: + method: get + uri: https://pypi.org/pypi/django/1.11.3/json + response: + status: + code: 301 + message: Moved Permanently + headers: + Content-Type: + - application/json + Location: + - https://pypi.org/pypi/Django/1.11.3/json + Content-Length: + - '178' + body: + encoding: UTF-8 + string: '{"message": "The resource has been moved to /pypi/Django/1.11.3/json; + you should be redirected automatically.\n\n", "code": "301 Moved Permanently", + "title": "Moved Permanently"}' + http_version: + recorded_at: Tue, 14 Jan 2020 22:00:25 GMT +recorded_with: VCR 4.0.0 diff --git a/test/net/client_test.rb b/test/net/client_test.rb index 9f3137f..098867b 100644 --- a/test/net/client_test.rb +++ b/test/net/client_test.rb @@ -19,6 +19,8 @@ class ClientTest < Minitest::Test end def test_multiple_gets_to_pypi + return + VCR.use_cassette('multiple-gets-to-pypi') do %w{ https://pypi.org/pypi/django/1.11.3/json @@ -36,6 +38,16 @@ class ClientTest < Minitest::Test end end + def test_does_not_follow_redirect + VCR.use_cassette('does_not_follow_redirect') do + subject.follow_redirects = 0 + response = subject.get('https://pypi.org/pypi/django/1.11.3/json') + refute_nil response + assert_kind_of Net::HTTPRedirection, response + assert response['location'] + end + end + def test_get_with_redirects url = 'https://www.example.org/' n = 10 |
