Created
November 19, 2013 23:46
-
-
Save invisiblefunnel/7554680 to your computer and use it in GitHub Desktop.
Infinite redirects with FakeWeb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe Requester do | |
| let(:requester) do | |
| Class.new{ include Requester }.new | |
| end | |
| describe ".get" do | |
| it "limits the number of redirects to follow" do | |
| uri = 'http://www.example.com/_status' | |
| redirect = Net::HTTPRedirection.new('1.1', '302', 'Found') | |
| redirect['Location'] = uri | |
| FakeWeb.register_uri(:get, uri, response: redirect) | |
| expect { | |
| requester.get(url) | |
| }.to raise_error ArgumentError, "too many redirects" | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment