Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Created November 19, 2013 23:46
Show Gist options
  • Select an option

  • Save invisiblefunnel/7554680 to your computer and use it in GitHub Desktop.

Select an option

Save invisiblefunnel/7554680 to your computer and use it in GitHub Desktop.
Infinite redirects with FakeWeb
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