Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.24 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.24 KB

Stubber

Swift CocoaPods Build Status Codecov

A minimal method stub for Swift.

At a Glance

import Stubber

final class StubUserService: UserServiceProtocol, Stub {
  func follow(userID: Int) -> String {
    return stubbed(follow, args: userID)
  }

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

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

Installation

pod 'Stubber'

License

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