Latest 0.0.4
Homepage https://github.com/JellyfishProject/JellyfishKit
License MIT
Platforms ios 8.0, osx 10.10
Frameworks Foundation, JavaScriptCore
Authors

pipeline status coverage report

What is this?

Jellyfish is a library that parse .api files and stub all web request according to the file contents.

TODO

  • [x] Read .api files and stub requests
  • [x] Custom matching handler
  • [ ] Provide options to match json schema

Vision

Jellyfish

When in testing environment, Jellyfish should serve as api endpoint for the app.

UI Tests and Unit Tests don’t need to stub web request with this framework.

Jellyfish

As in production environment, we can just remove Jellyfish and the app should make request to production server and perform normally.

Dependency

Usage

Start a stub with .apib file

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

For example, when use with 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:)


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)!)
}

Latest podspec

{
    "name": "Jellyfish",
    "version": "0.0.4",
    "summary": "API Blueprint mocking in Swift",
    "description": "Jellyfish is an API Blueprint Parser with stubbing written in Swift",
    "homepage": "https://github.com/JellyfishProject/JellyfishKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Yeung Yiu Hung": "[email protected]"
    },
    "social_media_url": "https://twitter.com/darkcl_dev",
    "swift_version": "3.2",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    },
    "source": {
        "git": "https://github.com/JellyfishProject/JellyfishKit.git",
        "tag": "0.0.4"
    },
    "source_files": [
        "Sources/**/*.{h,m,swift}",
        "ext/**/*.{h,m,swift}"
    ],
    "frameworks": [
        "Foundation",
        "JavaScriptCore"
    ],
    "resources": "Sources/Jellyfish/Wrapper/drafter.js"
}

Pin It on Pinterest

Share This