O'Reilly logo

RubyMotion iOS Development Essentials by Abhishek Nalwaya, Akshat Paul

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

Functional testing

RubyMotion lets us write functional tests for our controllers and interacts with its views through a set of high-level event generating APIs, by leveraging the functionality of Apple's UIAutomation framework without forcing us to write the tests in JavaScript.

Let's now write tests for user interface of the same application. In the following test case, we will test whether we have a label and a button on the screen.

Create the spec file restro_view_controller_spec.rb in the spec folder:

it "should have a label and a button" do
  view('Click Button').should.not.equal nil
  button = view('Click Me')
  button.should.not.equal nil
  button.isEnabled.should.equal true
end

The view(label) property returns the view that matches the specified ...

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