Skip to content

chungkil/Stubber

 
 

Repository files navigation

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.

About

A minimal method stub for Swift

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 86.2%
  • Ruby 13.8%