Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass the adapter option in initializer, pass it to HTTPI when fetching remote WSDL #44

Merged
merged 2 commits into from
May 4, 2014

Conversation

Envek
Copy link
Contributor

@Envek Envek commented Apr 27, 2014

It will be useful for those people who need to use different HTTPI adapters for different services, see savonrb/savon#564

I've bumped gem version as there is related pull request in savon that depend on it: savonrb/savon#566.

I don't know, how to test this, please tell me any ideas and suggestions, I'll write tests and append it to this request.

…dapter to fetch remote WSDL.

There is no tests yet.

Bumped version for use in savon gemspec.
@tjarratt
Copy link
Contributor

Just thinking out loud, but it seems like the best way to test this might be to make a fake adapter that just records calls, then you could have an assertion that the fake adapter was called at some point with the expected arguments.

The fake might look something like this... (shamelessly stolen from the httpi docs)

class FakeAdapter < HTTPI::Adapter::Base

  register :my_adapter, deps: %w(some_http_client)

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

  attr_reader :client

  def request(method)
    @@methods ||= []
    @@methods.push method
    response = @client.request(method, @request.url, @request.body)

    Response.new(response.code, response.header, response.content)
  end
end

# in test, you could assert on class variables after the requests have been made
expect(FakeAdapter.class_variable_get(:@@requests).size).to eq(1)
expect(FakeAdapter.class_variable_get(:@@requests)[0].url).to eq("http://example.org")
expect(FakeAdapter.class_variable_get(:@@methods)).to eq([:GET, :POST])

Also -- when this gets merged in, i'm probably going to bump the minor version number since this is a new feature. No need to bump it yourself.

@tjarratt tjarratt merged commit fe40669 into savonrb:master May 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants