O'Reilly logo

RubyMotion by Clay Allsopp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing App UI and Controllers

In addition to a basic RSpec testing framework, RubyMotion includes extensions that help us test complex interactions with views and a device. You can specifically test events such as taps, flicks, and pinches to ensure that your callbacks are functioning accordingly.

Let’s walk through an example of RubyMotion’s UI test helpers. We’re going to programmatically tap a UIButton and assert that some state has changed after the tap. Even better, we’ll make sure to visibly alter the UI after the tap to make it obvious while the test is running in the simulator.

Since UI testing requires a UIViewController instance, we need one of our own. Create the app/controllers directory and a button_controllerrb file within. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required