All Projects → raptorxcz → Rubicon

raptorxcz / Rubicon

Licence: MIT license
Swift parser + mock generator

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to Rubicon

mock
Utilities to help mock behavior, spy on function calls, stub methods, and fake time for tests.
Stars: ✭ 31 (-26.19%)
Mutual labels:  mock, spy
Cuckoo
Boilerplate-free mocking framework for Swift!
Stars: ✭ 1,344 (+3100%)
Mutual labels:  mock, protocol
phake
PHP Mocking Framework
Stars: ✭ 464 (+1004.76%)
Mutual labels:  mock, spy
mocka
Mocka - The complete testing framework for LUA and Nginx
Stars: ✭ 26 (-38.1%)
Mutual labels:  mock, spy
Swiftmockgeneratorforxcode
An Xcode extension (plugin) to generate Swift test doubles automatically.
Stars: ✭ 522 (+1142.86%)
Mutual labels:  mock, xcode-extension
spydriver
🕵️ Lightweight utility to intercept WebDriver and WebElement method calls.
Stars: ✭ 24 (-42.86%)
Mutual labels:  mock, spy
specs
Kontalk specifications and documentation
Stars: ✭ 20 (-52.38%)
Mutual labels:  protocol
wiresham
Simple TCP service mocking tool for replaying https://www.wireshark.org and http://www.tcpdump.org captured service traffic
Stars: ✭ 44 (+4.76%)
Mutual labels:  mock
net-protocol
golang模拟内核协议栈 实现链路层、网络层、传输层、应用层 用户态协议栈 ,基于虚拟网卡TUN/TAP
Stars: ✭ 129 (+207.14%)
Mutual labels:  protocol
SerialProtocol
A protocol for sending data between two Arduino devices, or between an Arduino and another device through a serial port
Stars: ✭ 36 (-14.29%)
Mutual labels:  protocol
qvcodefriend.github.io
Develop Xcode Extensions with JavaScript
Stars: ✭ 19 (-54.76%)
Mutual labels:  xcode-extension
hex-example
Little API to demonstrate various microservice design principles and technologies
Stars: ✭ 131 (+211.9%)
Mutual labels:  mock
clj-http-fake
Helper for faking clj-http requests.
Stars: ✭ 124 (+195.24%)
Mutual labels:  mock
diepindepth
Collection of protocol, memory, and other information for the browser game diepio
Stars: ✭ 39 (-7.14%)
Mutual labels:  protocol
diepssect
A public repo for hacky diep stuff - networking protocol, WebAssembly, memory editing, & physics
Stars: ✭ 26 (-38.1%)
Mutual labels:  protocol
Motoro
Smart contracts for decentralized rentals of vehicles.
Stars: ✭ 96 (+128.57%)
Mutual labels:  protocol
protocol-registry
This module allows you to set custom protocol handler for your nodejs app.
Stars: ✭ 45 (+7.14%)
Mutual labels:  protocol
gadgeto
Gadgeto! is a collection of tools that aim to facilitate the development of REST APIs in Go.
Stars: ✭ 38 (-9.52%)
Mutual labels:  mock
mqtt rs
MQTT broker in Rust
Stars: ✭ 23 (-45.24%)
Mutual labels:  protocol
definject
Unobtrusive Dependency Injector for Elixir
Stars: ✭ 46 (+9.52%)
Mutual labels:  mock

Rubicon

Rubicon

Build Status Build Status

Again available on AppStore https://itunes.apple.com/cz/app/rubicon/id1453837387

Swift parser + mock generator

Rubicon generates spys for protocol. Generating methods for parent protocol is not supported.

Example

input:

protocol Car {

    var name: String? { get }
    var color: Int { get set }

    func go()
    func load(with stuff: Int, label: String) throws -> Int
    func isFull() -> Bool
    func download() async throws -> [String]

}

Spy

output:

class CarSpy: Car {

    enum SpyError: Error {
        case spyError
    }
    typealias ThrowBlock = () throws -> Void

    var name: String?
    var color: Int

    struct Load {
        let stuff: Int
        let label: String
    }

    var goCount = 0
    var load = [Load]()
    var loadThrowBlock: ThrowBlock?
    var loadReturn: Int
    var isFullCount = 0
    var isFullReturn: Bool
    var downloadCount = 0
    var downloadThrowBlock: ThrowBlock?
    var downloadReturn: [String]

    init(color: Int, loadReturn: Int, isFullReturn: Bool, downloadReturn: [String]) {
        self.color = color
        self.loadReturn = loadReturn
        self.isFullReturn = isFullReturn
        self.downloadReturn = downloadReturn
    }

    func go() {
        goCount += 1
    }

    func load(with stuff: Int, label: String) throws -> Int {
        let item = Load(stuff: stuff, label: label)
        load.append(item)
        try loadThrowBlock?()
        return loadReturn
    }

    func isFull() -> Bool {
        isFullCount += 1
        return isFullReturn
    }

    func download() async throws -> [String] {
        downloadCount += 1
        try downloadThrowBlock?()
        return downloadReturn
    }
}

Mock

output:

class CarStub: Car {

    enum StubError: Error {
        case stubError
    }
    typealias ThrowBlock = () throws -> Void

    var name: String?
    var color: Int

    var loadThrowBlock: ThrowBlock?
    var loadReturn: Int
    var isFullReturn: Bool
    var downloadThrowBlock: ThrowBlock?
    var downloadReturn: [String]

    init(color: Int, loadReturn: Int, isFullReturn: Bool, downloadReturn: [String]) {
        self.color = color
        self.loadReturn = loadReturn
        self.isFullReturn = isFullReturn
        self.downloadReturn = downloadReturn
    }

    func go() {
    }

    func load(with stuff: Int, label: String) throws -> Int {
        try loadThrowBlock?()
        return loadReturn
    }

    func isFull() -> Bool {
        return isFullReturn
    }

    func download() async throws -> [String] {
        try downloadThrowBlock?()
        return downloadReturn
    }
}

Dummy

output:

class CarDummy: Car {

    var name: String? {
        fatalError()
    }
    var color: Int {
        get {
            fatalError()
        }
        set {
            fatalError()
        }
    }

    func go() {
        fatalError()
    }

    func load(with stuff: Int, label: String) throws -> Int {
        fatalError()
    }

    func isFull() -> Bool {
        fatalError()
    }

    func download() async throws -> [String] {
        fatalError()
    }
}

Usage in tests:

let carSpy = CarSpy()

...

XCTAssertEqual(carSpy.goCount, 1)
XCTAssertEqual(carSpy.load.count, 1)
XCTAssertEqual(carSpy.load[0].stuff, 2)
XCTAssertEqual(carSpy.load[0].label, "name")

CLI

Rubicon cli can generate mocks for every protocol in folder. Script runs through every swift file and find every protocol definition. Result is printed at standard out.

example:

$ ./rubicon --spy .

Options:

--mocks path - generates spies (deprecated)

--spy path - generates spies

--stub path - generates stubs

--dummy path - generates dummies

Xcode extension

Xcode extension can generate Spy for every or selected protocol in current file. Spy can be written to source file or pasteboard.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].