TDDとVimと

578ee81d12e579160e63815b92c4a0e4?s=47 Yuta Totz
October 23, 2015

 TDDとVimと

RailsまわりのTDDと、Vimについて。

578ee81d12e579160e63815b92c4a0e4?s=128

Yuta Totz

October 23, 2015
Tweet

Transcript

  1. TDD ͱ Vim ͱ Red-Green-Refactoring Cycle with Vim

  2. Resume • Introduction • What is “test”? • TDD on

    Red-Green-Refactor Cycle • TDD by Vim • Demo • Conclusion • Links and Books
  3. ࣗݾ঺հ

  4. ͱͭ ށ௩ ༎ଠ (@totzyuta) OneBox Inc. ίʔώʔ ݉ WebΤϯδχΞ

  5. ςετɺॻ͍ͯ·͔͢ʁ

  6. What is “test”?

  7. What is test? • ΞϓϦέʔγϣϯ͕ਖ਼͘͠ಈ͘͜ͱΛอূ͢ ΔͨΊͷΞϓϦέʔγϣϯͰ͸ͳ͍ίʔυ • ୯ମςετɺػೳςετɺ૯߹ςετ • (ݺͼํͷఆٛ͸͍͋·͍)

    • UnitςετͱFeatureςετ
  8. Categories of Tests • Unitςετ • ૄ݁߹తͳUnit͝ͱͷ࠴຿Λอূ͢Δ • associationͷਖ਼͠͞ͷ୲อ •

    Featureςετ • Unitؒͷ݁߹ • => ػೳશମͱͯ͠ͷಈ͖ͷਖ਼͠͞Λอূ͢Δ • Model, Controller, ViewΛ۲ࢗ͠Ͱ͖Δʂ
  9. Testing Frameworks • Minitest • Railsඪ४ (DHHਞ) • ೔ຊͰ΋࠷ۙͪΐͬͱ࢖͏ਓ૿͖͑ͯͨ •

    RSpec • ͳΜ͔Ή͠Ζඪ४Έ͍ͨʹͳͬͯͨ • ൈຊతͳ࢓༷มߋ͕ಘҙ
  10. 3 Principles of Writing Tests • ςετ͸৴པͰ͖Δ΋ͷͰ͋Δ͜ͱ • ςετ͸؆୯ʹॻ͚Δ͜ͱ •

    ςετ͸؆୯ʹཧղͰ͖Δ͜ͱ ref. Everyday Rails - RSpecʹΑΔRailsςετೖ໳ - Aaron Sumner, Junichi Ito, AKIMOTO Toshiharu, ৼߐ ڕ
  11. TDD on Red-Green- Refactor Cycle

  12. “TDD is dead.” — David Heinemeier Hansson

  13. What is TDD? • ʮϏδωεϓϩάϥϜΛॻ͘લʹɺςετίʔ υΛॻ͘͜ͱʯ • ςετ͕࢓༷ॻʹͳΔ (!!) •

    Red-Green-Refactor Cycle
  14. Flow of TDD on Red-Green-Refactor Cycle 1. ςετͰઃܭॻΛॻ͘ (RED) 2.

    ࠷଎͔ͭ࠷΋؆୯ʹςετΛ௨͢ίʔυΛॻ͘ (GREEN) • ͍ͭ͜͸ςετίʔυͷςετ 3. ϦϑΝΫλϦϯά (Refactor) • ͜Ε͕ຊؾͷ࣮૷ • “ϦϑΝΫλϦϯά”ͬͯ΍ͭͱ͸ͪΐͬͱҧ͏ • Red͕ΘΔ͍ɺGreen͕Α͍Ͱ͸ͳ͍ʂ ref. cookpad 2015 summer internship TDD by Yoshiori SHOJI
  15. TDD - ϝϦοτᶃ • ςετίʔυΛઌʹॻ͘͜ͱʹΑͬͯɺࣗ෼ ͕࡞Δ΂͖ϓϩάϥϜ͕໌֬Խ͢Δɻ • ࣄલʹ࡞੒͢ΔϓϩάϥϜΠϝʔδ͕ੜ·Ε ΔͨΊ࢓༷ᴥᴪʹؾͮ͘ػձ͕ૣΊʹ๚Ε Δɻ

  16. TDD - ϝϦοτᶅ • ςετίʔυ͕ඞͣશͯ࡞੒͞ΕΔ • Ϟνϕʔγϣϯ • ෆ҆Λ๊͑ͨ··ͷ։ൃ͞Α͏ͳΒ

  17. Vim

  18. VimͰRailsͳϓϥάΠϯ • jodosha/vim-greenbar • jodosha/vim-devnotes • dbext.vim • tpope/rails.vim •

    The-NERD-tree
  19. VimͰRailsͳϓϥάΠϯ • bronson/vim-trailing-whitespace • tpope/vim-endwise • vim-scripts/AnsiEsc.vim

  20. ුؾ૬ख

  21. Demo

  22. Demo $ rails new coedotask $ rails g scaffold Task

    name:string time:integer • λεΫ؅ཧΞϓϦέʔγϣϯ - coedotask • ͜Εʹ Task.calc_total_time Λ௥Ճ͠·͢ʂ
  23. Flow of TDD on Red-Green-Refactor Cycle 1. ςετͰઃܭॻΛॻ͘ (RED) 2.

    ࠷଎͔ͭ࠷΋؆୯ʹςετΛ௨͢ίʔυΛॻ͘ (GREEN) • ͍ͭ͜͸ςετίʔυͷςετ 3. ϦϑΝΫλϦϯά (Refactor) • ͜Ε͕ຊؾͷ࣮૷ • “ϦϑΝΫλϦϯά”ͬͯ΍ͭͱ͸ͪΐͬͱҧ͏ • Red͕ΘΔ͍ɺGreen͕Α͍Ͱ͸ͳ͍ʂ ref. cookpad 2015 summer internship TDD by Yoshiori SHOJI
  24. Conclusion • TDD͸։ൃऀΛ޾ͤʹͯ͘͠ΕΔ (?) • “TDD is dead” ͔෼͔Βͳ͍͚ͲͻͱΓͻͱ Γͷ࣮ફ͕Web։ൃʹ͓͚ΔςεςΟϯάͷ

    ະདྷΛܾΊ͍ͯ͘ • ྘ʹͳͬͯͨͷ͍͠
  25. ͋Δ೔ͷ͜ͱ

  26. None
  27. *ŋʄƅŋ*:.Ň..Ň.:*ŋ'( ƅ˜ƅ*)'ŋ*:.Ň. .Ň.:*ŋʄƅŋ*

  28. None
  29. *ŋʄƅŋ*:.Ň..Ň.:*ŋ'( ƅ˜ƅ*)'ŋ*:.Ň. .Ň.:*ŋʄƅŋ*

  30. ॻ੶ • Everyday Rails Testing with RSpecTDD • Aaron Sumner

  31. ࢀߟ • BDDʹ͍ͭͯࣗ෼ͳΓʹ·ͱΊͯΈͨ • TDD is dead. Long live testing.

    • Effective TDD With Ruby: Time & Flow
  32. ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ