Stubber 0.5.0

Stubber 0.5.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2017
SwiftSwift Version 3.1
SPMSupports SPM

Maintained by Suyeol Jeon.


Downloads

Total202
Week82
Month202

Installs

Test Targets7
Test WeekTests This week 7
powered by Segment

GitHub

Stars5
Watchers2
Forks1
Issues0
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 52


Stubber 0.5.0

  • By
  • Suyeol Jeon

A minimal method stub for Swift.

At a Glance

import Stubber

final class StubUserService: UserServiceProtocol {
  func follow(userID: Int) -> String {
    return Stubber.invoke(follow, args: userID)
  }

  func edit(userID: Int, name: String) -> Bool {
    return Stubber.invoke(edit, args: (userID, name))
  }
}

func testMethodCall() {
  let userService = StubUserService()
  Stubber.register(userService.follow) { userID in "stub-\(userID)" } // stub
  Stubber.follow(userID: 123) // call
  XCTAssertEqual(Stubber.executions(userService.follow).count, 1)
  XCTAssertEqual(Stubber.executions(userService.follow)[0].arguments, 123)
  XCTAssertEqual(Stubber.executions(userService.follow)[0].result, "stub-123")
}

Installation

pod 'Stubber'

License

Stubber is under MIT license. See the LICENSE for more info.