Sha256: 7364799ded805b0e194e553946af7eebf4b5f2302160a83eeb67c35d26947ba9
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
require 'rack/test' module Capybara::RackTestJson class Client include Rack::Test::Methods attr_accessor :app def initialize(app) @app = app end %w[ get post put delete ].each do |method| module_eval %{ def #{method}(uri, params = {}, env = {}, &block) env.merge(:method => "#{method.upcase}", :params => params) request_with_follow_redirect(uri, env, &block) end } end def request_with_follow_redirect(uri, env) request(uri, env) (5+1).times do if last_response.redirect? request(last_response["Location"], env.merge(:method => "GET")) else return end end # 6 times redirect cause InfiniteRedirectError raise Capybara::InfiniteRedirectError, "redirected more than 5 times, check for infinite redirects." end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capybara-json-0.2.0 | lib/capybara/rack_test_json/client.rb |