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 accessibility label. The view
command traverses down through the view hierarchy, starting from the current window. If no view matches our condition, it keeps retrying it until the timeout, which defaults to three seconds. This means you don...