Sha256: 5229c9f08eca722b3ad78bcc1128664f04da129e4dff75a0e30232f9a3935b5b

Contents?: true

Size: 723 Bytes

Versions: 149

Compression:

Stored size: 723 Bytes

Contents

require 'ostruct'

module HttpRequestTestHelper
  def http_request(method, uri, options = {})
    begin
      uri = URI.parse(uri)
    rescue
      uri = Addressable::URI.heuristic_parse(uri)
    end
    response = nil
    clazz = ::Net::HTTP.const_get("#{method.to_s.capitalize}")
    req = clazz.new("#{uri.path}#{uri.query ? '?' : ''}#{uri.query}", options[:headers])
    req.basic_auth uri.user, uri.password if uri.user
    http = ::Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true if uri.scheme == "https"
    response = http.start {|http|
      http.request(req, options[:body])
    }
    OpenStruct.new({
      :body => response.body,
      :headers => response,
      :status => response.code })
  end
end

Version data entries

149 entries across 147 versions & 11 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/webmock-1.20.4/test/http_request.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/webmock-1.20.4/test/http_request.rb
webmock-1.22.6 test/http_request.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/webmock-1.22.5/test/http_request.rb
webmock-1.22.5 test/http_request.rb
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/webmock-1.22.3/test/http_request.rb
webmock-1.22.3 test/http_request.rb
webmock-1.22.2 test/http_request.rb
webmock-1.22.1 test/http_request.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/webmock-1.8.11/test/http_request.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/webmock-1.8.11/test/http_request.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/webmock-1.8.11/test/http_request.rb
webmock-1.21.0 test/http_request.rb
webmock-1.20.4 test/http_request.rb
webmock-1.20.3 test/http_request.rb
webmock-1.20.2 test/http_request.rb
webmock-1.20.1 test/http_request.rb
webmock-1.20.0 test/http_request.rb
webmock-1.19.0 test/http_request.rb
whos_dated_who-0.1.0 vendor/bundle/gems/webmock-1.18.0/test/http_request.rb