Предоставление ответа Swift 3.0, который также использует фреймворк Quick/Nimble и выполняет Segue путем нажатия на кнопку, которая выполняет Segue в пространстве просмотра.
// Note: there's also a beforeEach {} that sets up the mainViewController
describe("navigation") {
beforeEach {
// Access the view to trigger MainViewController.viewDidLoad().
let _ = mainViewController.view
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let window = appDelegate.window
window?.rootViewController = mainViewController
}
describe("the views navigationBar", closure: {
describe("left bar button item", closure: {
context("when pressed", closure: {
it("displays SomeViewController", closure: {
let item = mainViewController.navigationBar.topItem
let addItem = item?.leftBarButtonItem
tap(addItem!)
expect(mainViewController?.presentedViewController).toEventually(beAnInstanceOf(SomeViewController.self))
})
})
})
})
}
Для справки кран() метод:
func tap(_ barButtonItem: UIBarButtonItem) {
let _ = barButtonItem.target?.perform(barButtonItem.action, with: barButtonItem)
}