KaneCheshire / Peasy

A pure Swift mock server for embedding and running directly within iOS/macOS UI tests. Easy peasy.
MIT License
38 stars 10 forks source link

Load JSON body data from file #9

Closed samdods closed 4 years ago

samdods commented 4 years ago

It would be nice if you could load JSON from a file to respond with, like so:

extension Response {
    public init(status: Status, headers: [Header] = [], bodyFromJSONFile: String) {
        // load body data as JSON from given file
    }
}
KaneCheshire commented 4 years ago

Wouldn't be impossible for sure, and not too much extra hassle to add a new init either. Would there be a way to automatically detect the right bundle from within the Response's init? Would be nasty to expect people to also pass in a bundle so would want to avoid that if possible

KaneCheshire commented 4 years ago

Ah I know, if I create an init that takes a URL to load you can just pass in the URL to a file, so Peasy doesn't need to care about the bundle.