Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active January 27, 2017 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/faa357aaee8b98b8b61634aa87b6b496 to your computer and use it in GitHub Desktop.
Save chelseatroy/faa357aaee8b98b8b61634aa87b6b496 to your computer and use it in GitHub Desktop.
Load from Storyboard Example iOS
import XCTest
import Hamcrest
import FutureKit
@testable import MyExampleApp
class ExampleViewControllerTest: XCTestCase {
var fakeExampleService: FakeExampleService!
override func setUp() {
super.setUp()
fakeExampleService = FakeExampleService()
}
func testServiceCallInExampleViewController() {
let stubbedResponse = MyExampleAppResponse(name: "Johnny Appleseed", favoriteFruit: "apples")
fakeExampleService.stubbedResponse = stubbedResponse
let controller = ExampleViewController.loadFromStoryboard(fakeExampleService: fakeExampleService)
assertThat(controller.view, present())
controller.searchBar.text = "Appleseed"
controller.didTapButtonToCallService(NSObject())
assertThat(fakeExampleService.lastRequest, presentAnd(equalTo("Appleseed")))
assertThat(controller.nameField.text, presentAnd(equalTo("Johnny Appleseed")))
assertThat(controller.favoriteFruitField.text, presentAnd(equalTo("apples")))
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment