RubyMotion 1.15ですごいアップデートが来るよってlrzさんが言ってました.
Integrating a super cool new feature in RubyMotion. Will ship next week.
— Laurent Sansonettiさん (@lrz) 6月 29, 2012
それが今日来たのですが,スーパークールなニューフィーチャーはTestFrameworkに関するものでした.
今までRubyMotionはbaconを使ったTestFrameworkが使われていて,
rake spec
とするとSimulatorが実行されメソッドを呼んで値を検証してという形でした.
今回のアップデートでは,指でタップしたりDeviceイベント(画面を回転させたり)といったこともテストで出来るようになりました.
ObjC + XcodeだとjsでUIAutomationのテストを行うらしいんですが(やったことない),その機能がRubyMotionのbaconに統合された感じです.
describe "The Timer view controller" do
tests TimerController
it "start a timer" do
tap 'Start'
controller.timer.isValid.should == true
end
end
とすれば,Start
というLabelのついてるButtonをタップしてcontrollerのtimerを検証してます.
実際にVideoを見てもらうのが早いと思います.Viewがガンガン動いて面白いです.
公式Blogの情報はこちら
ドキュメントはこちら
7/22(日)に行われる第一回RubyMotion勉強会での発表ネタは今回のアップデートのテストに関することにしようと思います. あと5人ぐらい空きがあるようですね.
修正: 第一回RubyMotion勉強会は 7/22(日) でした.
他のアップデートは↓のような感じです.
更新履歴(訳)
- UIAutomationの機能を使えるTestが書けるようになったし,jsじゃなくてpure Rubyで書ける.
- spec/helpersの中のファイルが
rake spec
で使われるようになったよ rake spec
にfileオプションが追加されて,テストする対象が選べるようになったよ.RUBYMOTION_ENV
で実行時にtestなのかdevelopmentなのかreleaseなのかを判別出来る様になった.- rake staticが追加されてuniversal statc libraryを作れるようになった.
- weak frameworkのサポート(app.weak_freameworks << ‘Twitter’とかする)
- symlinkのファイルがresourceディレクトリに入っていた場合にコピーされてたのを修正.
更新履歴(原文)
= RubyMotion 1.15 =
* Improved the spec framework to leverage UIAutomation's functionality. This
lets you write functional tests on views and controllers by using the same
event generators, but in pure Ruby (and not Javascript).
Check http://www.rubymotion.com/developer-center/articles/testing for more
information about the new API. Feature contributed by Eloy Duran.
* Introduced spec helpers. `rake spec' will now honor the files inside the
`spec/helpers' directory (if it exists) and compile them before the spec
files.
* Introduced the `files' option to `rake spec', which can be used to filter
the spec files that should be run. Filters can be either the basename of
a spec file or its full path, and are separated by a comma.
Example: rake spec files=main_spec,kvo_spec,spec/foo_spec.rb
* Introduced the RUBYMOTION_ENV constant in the runtime which can have one of
the following string values: 'test', 'development' and 'release'.
* Introduced the `rake static' task which creates a universal static library
containing the project's object files and the RubyMotion runtime, which is
suitable for inclusion in Objective-C/Xcode projects.
* Introduced weak frameworks support. The `app.weak_frameworks' setting can
be set to an array of framework names, similar to how `app.frameworks'
works (ex. app.weak_frameworks += ['Twitter']). Patch by Satoshi Ebisawa.
* Fixed a bug in the build system where files within symlinks inside of the
resources directory would not be copied. Patch by Nick Quaranto.