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:
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. Before0.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 withfaraday
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: