Last active
January 27, 2017 23:24
-
-
Save chelseatroy/faa357aaee8b98b8b61634aa87b6b496 to your computer and use it in GitHub Desktop.
Load from Storyboard Example iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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