Coder Social home page Coder Social logo

saddle's People

Contributors

bmorearty avatar conarro avatar mlewislogic avatar nelgau avatar renzominelli avatar santiagorodriguez96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

saddle's Issues

Error when `path_prefix` is set and `Faraday::Adapter::Test::Stubs` is used

In saddle version 0.1.0 the faraday version was bumped to ~> 0.9.0. With this change the stubs changed behaviour.
Before 0.1.0:

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 party

After 0.1.0

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:

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('?a=1') # Faraday::Adapter::Test::Stubs::NotFound (no stubbed request for get http://localhost/api/v1/?a=2 )

stubs.get('/api/v1/test') { [200, {}, 'party'] }
default_client.requester.get('test') # Returns "party"
default_client.requester.get('/test') # Returns "party"

Before it has some strange behaviour:

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('?a=1') # Returns "party"

stubs.get('/api/v1/test') { [200, {}, 'party'] }
default_client.requester.get('test') # Faraday::Adapter::Test::Stubs::NotFound (no stubbed request for get /api/v1/api/v1/test )
default_client.requester.get('/test') # Returns "party"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.