Skip to content

Conversation

@alanoliveira
Copy link

Description

This PR makes Test adapter constructor able to receive stubs as a keyword argument.

Details

The Test adapter expects to receive the stubs as a positional argument. It is great because in the most of cases we want to use it like

Faraday.new do |builder|
  builder.adapter :test, stubs
end

But it is not compatible with Faraday.default_adapter_options as it must to be a hash.

def build
raise_if_locked
block_given? ? yield(self) : request(:url_encoded)
adapter(Faraday.default_adapter, **Faraday.default_adapter_options) unless @adapter
end

So we can't do something like

RSpec.configure do |config|
  config.before :context, :stub_api do
    Faraday.default_adapter = :test
    Faraday.default_adapter_options = # must be a hash
  end
end

I changed the Test adapter constructor to also accept positional argument instead of change RackBuilder::Handler#builder method because the way to pass options to adapters is using hash.

@alanoliveira alanoliveira closed this by deleting the head repository Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant