Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RubyMotion 1.15で追加されたtest周りの話

597eefef02f3db2d6e282070b4ef2cf4?s=47 pochi
July 24, 2012

RubyMotion 1.15で追加されたtest周りの話

第一回RubyMotion 勉強会で話した資料
その他RubyMotion系の解説記事は http://pchw.github.io/blog/categories/rubymotion/ へどうぞ

597eefef02f3db2d6e282070b4ef2cf4?s=128

pochi

July 24, 2012
Tweet

Transcript

  1. RubyMotion 1.15Ͱ௥Ճ͞ΕͨtestपΓͷ࿩ RubyMotion ษڧձ #1 @pchw 12೥7݄25೔ਫ༵೔

  2. intro Άͪ @pchw iPhoneΞϓϦͱ͔WebαʔϏεͱ͔ ࡞ͬͯ·͢ http://pchw.github.com/ 12೥7݄25೔ਫ༵೔

  3. ͬ͛͢ʔΞοϓσʔτ͕དྷΔͬͯ 12೥7݄25೔ਫ༵೔

  4. Viewͱ͔Controllerͱ͔ͷςετͰͨ͠ 12೥7݄25೔ਫ༵೔

  5. ͳʹ͕ग़དྷΔͷʁ ͜͜ʹSimulator͕ TestͰάϦάϦಈ͘ಈ ը͕షͬͯ͋ͬͨ 12೥7݄25೔ਫ༵೔

  6. 12೥7݄25೔ਫ༵೔

  7. UIAutomationʹΑΔςετ Objective-CͰΞϓϦॻ͍ͯΔਓ ͸࣮͸લ͔Βग़དྷͯͨ 12೥7݄25೔ਫ༵೔

  8. 12೥7݄25೔ਫ༵೔

  9. UIAutomationʹΑΔςετ͕Մೳʹ •ObjC •࣮͸લ͔Βग़དྷͯͨ •Ͱ΋javascript •RubyMotion •ΞϓϦ => Ruby •ςετ =>

    Ruby 12೥7݄25೔ਫ༵೔
  10. ࣗಈԽग़དྷΔૢ࡞ view event tap flick pinch drag rotate device event

    rotate acceleration shake 12೥7݄25೔ਫ༵೔
  11. ४උ(app/app_delegate.rb) class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) return true if RUBYMOTION_ENV

    == 'test' not for full application acceptance tests. Therefore you should not let the application launch as normal. 12೥7݄25೔ਫ༵೔
  12. ॻ͖ํ(spec/***.rb) describe “hoge” do tests <ControllerName> it “fugas” do controller.fuga.should

    == ‘fuga’ end end 12೥7݄25೔ਫ༵೔
  13. viewͷࢦఆ describe ‘controlelr has label’ do tests Hoge it ‘has

    label’ do view(‘hoge’).should.not == nil end end class Hoge < UIViewController def viewDidLoad label = UILabel.alloc.init label.accessibilityLabel = “hoge” end end 12೥7݄25೔ਫ༵೔
  14. Ͳ͏΍ͬͯݟ͚ͭͯΔͷ def _viewByName(accessibilityLabel) subviews.each do |subview| ʢུʣ 12೥7݄25೔ਫ༵೔

  15. ςετ࣮ߦ $ rake spec $ rake spec files=spec/hoge_spec.rb, spec/fuga_spec.rb 12೥7݄25೔ਫ༵೔

  16. rm-redgreen Before After 12೥7݄25೔ਫ༵೔

  17. reference Writing Test for RubyMotion Appsʢެࣜʣ http://www.rubymotion.com/developer-center/articles/testing/ Functional View and

    Controller Testing with RubyMotionʢެࣜBlogʣ http://blog.rubymotion.com/post/26489000626/functional-view-and-controller-testing-with-rubymotion HipByte / RubyMotionʢtest/bacon-ui/spec಺ʹTest Sample͕͋Γ·͢ʣ https://github.com/HipByte/RubyMotion rm-redgreen https://github.com/mdks/rm-redgreen 12೥7݄25೔ਫ༵೔