You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stubs = Faraday::Adapter::Test::Stubs.new
default_client = Saddle::Client.create(:stubs => stubs, :path_prefix => 'api/v1')
stubs.get('/api/v1') { [200, {}, 'party'] }
default_client.requester.get('')
# Returned error
# Faraday::Adapter::Test::Stubs::NotFound (no stubbed request for get http://localhost/api/v1/ )
It seems that when making a request to '' the path that is used is the path_prefix + '/'.
The stub with faraday version < 0.9.0 also added the '/' at the end, but this changed in 0.9.0, where they started using Faraday::Utils.normalize_path which ends up using URI.
Is the '/' expected to be added at the end of the path or is this a bug? If it's the expected way just changing the stub to
stubs.get('/api/v1/') { [200, {}, 'party'] }
fixes the issue.
As a side note, after 0.1.0 when making a request with something rather than blank it always adds the '/'. For example:
The text was updated successfully, but these errors were encountered:
RenzoMinelli
changed the title
Error when 'path_prefix' is set and `Faraday::Adapter::Test::Stubs' is used
Error when path_prefix is set and Faraday::Adapter::Test::Stubs is used
May 31, 2023
I like the proposal to add the / to the end of the path in the stub invocation. Seems the cleanest way to align with how Farady does path normalization.
In
saddle
version0.1.0
thefaraday
version was bumped to~> 0.9.0
. With this change the stubs changed behaviour.Before
0.1.0
:After
0.1.0
It seems that when making a request to '' the path that is used is the
path_prefix
+ '/'.The stub with
faraday
version< 0.9.0
also added the '/' at the end, but this changed in0.9.0
, where they started usingFaraday::Utils.normalize_path
which ends up usingURI
.Is the '/' expected to be added at the end of the path or is this a bug? If it's the expected way just changing the stub to
fixes the issue.
As a side note, after
0.1.0
when making a request with something rather than blank it always adds the '/'. For example:Before it has some strange behaviour:
The text was updated successfully, but these errors were encountered: