Giter Club home page Giter Club logo

Comments (6)

johndpope avatar johndpope commented on May 26, 2024

Fyi - Iā€™d encourage leveraging this code base

OHHTTPStubs
https://github.com/AliSoftware/OHHTTPStubs/blob/master/Examples/Swift/MainViewController.swift

I took this code one step further and allowed Charles saved traffic to replay with one line

https://github.com/johndpope/HAR-playback-swift

from restofire.

rahul0x24 avatar rahul0x24 commented on May 26, 2024

Thanks for sharing!

OHHTTPStubs are good but adding it as a dependency is something I would like to avoid. I am thinking more of a variable containing response as a string that will simulate the actual API on the basis of launch argument.

So it is more aligned to testing your views with the api contract before the actual api is created.
I am not sure about the implementation right now and what all things to consider while implementing this functionality.

Thoughts?

from restofire.

johndpope avatar johndpope commented on May 26, 2024

I've seen this cruder approach with json string payloads from junior coders - when the end point api mutates - you end up with a bunch of rotten code.
It also leaves a lot of case switching out to if test // load this string just creates a pile of poo.
You can always fork OHHTTPStubs and simply rename it StubFire
The crux of use case from my POV - boils down to
enable stubbing
intercept specified end points.

if url == "/getFriends"
then load /parse using alamofire from a corresponding versioned json file with http status code 200.
api changes / load a different one.
disable stubbing.

Here's some code I crafted to load a response from swagger.
https://gist.github.com/johndpope/009b9301ef422daca4c3588aad7b337b

screen shot 2018-02-05 at 2 05 01 pm

https://github.com/AliSoftware/OHHTTPStubs/blob/master/Examples/Swift/MainViewController.swift

If you want to avoid third party dependencies - then by that rational you're also saying you want to not include Alamofire - which is crazy talk.

from restofire.

rahul0x24 avatar rahul0x24 commented on May 26, 2024

Thanks for sharing links. HAR-playback-swift looks very cool.

And nothing against using third party libraries but stubbing is a part of testing. Adding OHHTTPStubs as a dependency will force users to embed the framework inside their IPAs which they won't want to do. I will let users add them separately and create their own stubs.

from restofire.

johndpope avatar johndpope commented on May 26, 2024

you can target framework dependencies for different build configurations.
eg.
pod 'OHHTTPStubs' #, :configurations => ['Debug']

from restofire.

rahul0x24 avatar rahul0x24 commented on May 26, 2024

Thanks! Will investigate how can this be integrated with Carthage and SPM also.

from restofire.

Related Issues (20)

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.