Skip to content
drnic edited this page Sep 12, 2010 · 2 revisions

iPhoneRuby

Want to write iPhone apps with unit tests? Want to write them in Ruby?

This project adds a Ruby-based unit test framework to your iPhone/Objective-C project. This allows
you to write your unit tests in Ruby (test/unit, rspec, Shoulda, test/spec etc) and have them executed
upon your Objective-C code.

Although iPhone code is normally compiled to the ARM architecture (the iPhone uses ARM, not Intel or PPC chips)
we can test the code on an Intel/PPC machine by compiling it against a combination of standard Mac OSX frameworks
and some iPhone frameworks.

Theoretically you cannot compile Mac OSX code against the iPhone frameworks, since the latter are built against the ARM
architecture. So, this project aims to resolve this issue by generating pretend/mock iPhone classes based on the known,
public iPhone framework header files. Your Ruby tests can then mock out any expected functionality as requred.

NOTE: currently the project does not include the mock iPhone framework classes. Its under development.

Framework compatibility limitations

But, there are common frameworks between the iPhone and Mac OSX platforms. At last count here are the useful statistics:

  • 11 similarly named frameworks, such as Foundation and AddressBook;
  • 162 similarly named header files, such as Foundation/NSURL.h or AddressBook/ABAddressBook.h
  • 153 header files that are exactly the same

There is a generated complete list of Platform Differences.

This means that when you compile your iPhone code against Mac OSX frameworks (which is what you’ll do to test them using
this Ruby-based test framework), there may be inconsistencies in headers and behaviour. But, what you can do at the moment
is better than a kick in the teeth.

Clone this wiki locally