Sha256: a9d3ce9be6589c6e4738e14be7be6f14aa05b96b73ecd19f5d7bdd45f640b239

Contents?: true

Size: 1005 Bytes

Versions: 2

Compression:

Stored size: 1005 Bytes

Contents

# frozen_string_literal: true
require 'httpi/adapter/httpclient'

# Proxy adapter. Records all requests and passes them to HTTPClient
class AdapterForTest < HTTPI::Adapter::Base

  register :adapter_for_test

  def initialize(request)
    @@requests ||= []
    @@requests.push request
    @request = request
    @worker = HTTPI::Adapter::HTTPClient.new(request)
  end

  def client
    @worker.client
  end

  def request(method)
    @@methods ||= []
    @@methods.push method
    @worker.request(method)
  end

end

# Fake adapter with request recording.
# Takes path from url and returns fixture WSDL with that name.
class FakeAdapterForTest < HTTPI::Adapter::Base

  register :fake_adapter_for_test

  def initialize(request)
    @@requests ||= []
    @@requests.push request
    @request = request
  end

  attr_reader :client

  def request(method)
    @@methods ||= []
    @@methods.push method
    target = @request.url.path.to_sym
    HTTPI::Response.new(200, {}, Fixture.wsdl(target))
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
savon-2.13.1 spec/support/adapters.rb
savon-2.13.0 spec/support/adapters.rb