Sha256: 182a16977d24019406a715b993bfb07979d900fca6414f4f19133139ecfe33e1

Contents?: true

Size: 1.16 KB

Versions: 98

Compression:

Stored size: 1.16 KB

Contents

require 'ostruct'

module ExconSpecHelper

  def http_request(method, uri, options = {}, &block)
    Excon.defaults[:ssl_verify_peer] = false
    uri      = Addressable::URI.heuristic_parse(uri)
    uri      = uri.omit(:userinfo).to_s.gsub(' ', '%20')

    if Gem::Version.new(Excon::VERSION) < Gem::Version.new("0.29.0")
      options  = options.merge(:method => method, :nonblock => false) # Dup and merge
      response = Excon.new(uri).request(options, &block)
    else
      options  = options.merge(:method => method) # Dup and merge
      response = Excon.new(uri, :nonblock => false).request(options, &block)
    end

    headers  = WebMock::Util::Headers.normalize_headers(response.headers)
    headers  = headers.inject({}) do |res, (name, value)|
      res[name] = value.is_a?(Array) ? value.flatten.join(', ') : value
      res
    end

    OpenStruct.new \
      :body => response.body,
      :headers => headers,
      :status  => response.status.to_s,
      :message => ""
  end

  def client_timeout_exception_class
    Excon::Errors::Timeout
  end

  def connection_refused_exception_class
    Excon::Errors::SocketError
  end

  def http_library
    :excon
  end

end

Version data entries

98 entries across 96 versions & 9 rubygems

Version Path
cloudsmith-api-2.0.16 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.1 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-2.0.0 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-1.142.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-1.120.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb
cloudsmith-api-1.61.3 vendor/bundle/ruby/2.6.0/gems/webmock-1.24.6/spec/acceptance/excon/excon_spec_helper.rb