Sha256: ad8c80c4bc592cb0b91311e4145035ef694b2908116c323656001be0fcfe83cd
Contents?: true
Size: 828 Bytes
Versions: 6
Compression:
Stored size: 828 Bytes
Contents
require 'rack/proxy' require 'capybara/webmock' class Capybara::Webmock::Proxy < Rack::Proxy ALLOWED_HOSTS = allowed_hosts = ['127.0.0.1', 'localhost', /(.*\.|\A)lvh.me/] def call(env) @streaming = true super end def perform_request(env) request = Rack::Request.new(env) if allowed_host?(request.host) super(env) else headers = { 'Content-Type' => 'text/html', 'Access-Control-Allow-Origin' => '*', 'Access-Control-Allow-Methods' => '*', 'Access-Control-Allow-Headers' => '*' } ['200', headers, ['']] end end private def allowed_host?(host) ALLOWED_HOSTS.any? do |allowed_host| case allowed_host when Regexp allowed_host =~ host when String allowed_host == host end end end end
Version data entries
6 entries across 6 versions & 1 rubygems