Update podspec
Jellyfish is a library that parse .api files and stub all web request according to the file contents.
.api
When in testing environment, Jellyfish should serve as api endpoint for the app.
Jellyfish
UI Tests and Unit Tests don’t need to stub web request with this framework.
UI Tests
Unit Tests
As in production environment, we can just remove Jellyfish and the app should make request to production server and perform normally.
Start a stub with .apib file
.apib
import Jellyfish var jellyfish: Jellyfish = Jellyfish() jellyfish.stub(docPath: Bundle.main.path(forResource: "testing_normal_blueprint", ofType: "apib")!)
Stop the stub
jellyfish.stop()
When using URLSessionConfiguration, you need to call .jellyfishConfiguration
URLSessionConfiguration
.jellyfishConfiguration
For example, when use with Alamofire
Alamofire
import Alamofire sessionManager = Alamofire.SessionManager(configuration: .jellyfishConfiguration) sessionManager.request("https://example.com/message").responseString { result in print("==================Alamofire") print(result.description) }
You can override default matcher function with addMatcher(to:)
addMatcher(to:)
jellyfish.addMatcher(to: "/message") { req in let str: String = "This is a message" return APIResponse(headers: ["Server": "Custom Handler"], responseCode: 200, body: str.data(using: .utf8)!) }
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Jellyfish
What is this?
Jellyfish is a library that parse
.apifiles and stub all web request according to the file contents.TODO
.apifiles and stub requestsVision
When in testing environment,
Jellyfishshould serve as api endpoint for the app.UI TestsandUnit Testsdon’t need to stub web request with this framework.As in production environment, we can just remove
Jellyfishand the app should make request to production server and perform normally.Dependency
Usage
Start a stub with
.apibfileStop the stub
When using
URLSessionConfiguration, you need to call.jellyfishConfigurationFor example, when use with
AlamofireYou can override default matcher function with
addMatcher(to:)