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

cookpad-17day-tech-internship-2017-tdd

 cookpad-17day-tech-internship-2017-tdd

クックパッド17day技術インターンシップの前半、TDDへんの講義資料です

70e13d9877054026fda46d5a5b53a236?s=128

MOROHASHI Kyosuke

August 31, 2017
Tweet

Transcript

  1. TDD: Test Driven Development 2017-08-08 @moro ॾڮګհ

  2. ❌ ςεςΟϯάϑϨʔϜϫʔΫͷ࢖͍ํ
 ɹɹɹ(࣮श࣌ʹݸผʹฉ͍͍ͯͩ͘͞) ⭕ TDDͷૂ͍ ⭕ TDDΛऔಘ͢ΔͨΊͷΧλ ͖ΐ͏࿩͢͜ͱ 

  3. What is TDD?

  4. TDD = Test Driven
 Development

  5. ςετۦಈ։ൃ͸ɺϓϩάϥϛϯάதͷෆ҆Λ؅ཧ͢Δख๏ ͩɻෆ҆ͱ͸ʮ͜Ε͸ࠔ೉ͳ໰୊ͳͷͰɺ࠷ॳ͔Β͢΂ͯΛ ݟ௨ͤΔΘ͚Ͱ͸ͳ͍ʯͱ͍͏ਅͬ౰ͳײ֮ͷ͜ͱͩɻ ུ  5%%͸ϓϩάϥϛϯάதͷઃܭ൑அͱϑΟʔυόοΫͷؒʹ ͋ΔΪϟοϓΛೝࣝ͢Δ͜ͱͰ͋ΓɺͦͷΪϟοϓΛίϯτ ϩʔϧ͢Δٕ๏Ͱ΋͋Δɻ ςετۦಈ։ൃೖ໳

  6. ‣ ιϑτ΢ΣΞΛ࣮ߦ͠ɺͦͷ݁ՌΛ֬ೝͯ࣍͠ʹॻ͘ίʔ υΛܾΊΔɻ ‣ ςεςΟϯάϑϨʔϜϫʔΫ͕ͦΕΛࢧԉͯ͘͠ΕΔɻ ‣ ࣮ߦ͢ΔͨΊͷ४උ(σʔληοτΞοϓͳͲ) ‣ ࣮ߦ݁Ռͷࣗಈ֬ೝ ‣

    ܁Γฦ࣮͠ߦͷࢧԉ ϑΟʔυόοΫ 
  7. Why TDD?

  8. ʮಈ࡞͢Δ͖Ε͍ͳίʔυʯɺϩϯɾδΣϑϦʔ ζͷ͜ͷ؆ܿͳݴ༿͸ɺ5%% ςετۦಈ։ൃ ͷ ໨ඪͰ͋Δɻಈ࡞͢Δ͖Ε͍ͳίʔυ͸ɺ͋ΒΏ Δཧ༝ͰՁ஋͕͋Δɻ ᴷ,FOU#FDL

  9. ಈ࡞͢Δɺ͖Ε͍ͳίʔυ΁ ͖Ε͍ Ԛ͍ (͙͢ʹ͸)ಈ͔ͳ͍ ಈ࡞͢Δ ೋͭͷಓ͕͋Δ t-wada: says

  10. ‣ TDDͷʮςετʯͱ͍͏χϡΞϯε͕ಠΓา͖ͨ݁͠Ռɺ
 ʰݟΔ΂͖͸ΦϒδΣΫτͷৼΔ෣͍ʱͩͱ͍͏ཱ৔͕ݱΕͨɻ ‣ (ࢲ͡͠Μ͸ɺ࣮རͱͯ͠ͷҧ͍͸ͳ͍ͱ͍͏ཱ৔) ‣ ։ൃΛۦಈ͢ΔɺͦͷͨΊʹظ଴͢Δʮ;Δ·͍ʯΛ
 ςετίʔυͰදݱ͠ɺ࣮ߦ͠ɺϑΟʔυόοΫΛಘΔɻ ‣ assert଒ͳΒTDD,

    expect଒ͳΒBDDͱ͍͏࿩Ͱ͸ͳ͍ɻ FYI: TDDͱBDDͷҧ͍ 
  11. How to TDD?

  12. How to learn TDD?

  13. कɾഁɾ཭

  14. ‣ Ϩου৽͍͠ίʔυΛॻ͘લʹɺ·ͣ͸ࣦഊ͢ΔϢχοτςετΛॻ͘ɻ৽͠ ͍ίʔυͷҙਤΛςετͰࣔ͢ΜͩɻϨου͸ઃܭʹ͍͔ͭͯͬ͠Γߟ͑Δग़ ൃ఺ͩɻ ‣ άϦʔϯͱʹ͔͘ςετʹ੒ޭ͢ΔίʔυΛॻ͘ɻ࣮૷ͷ࠷ऴܗΛࢥ͍ඳ͚Δ ͳΒҰؾʹ࢓্͛ͯ͠·͑͹͍͍ɻͦ͜·Ͱͷࣗ৴͕ͳ͚Ε͹ɺ·ͣ͸ςετ ʹ੒ޭ͢Δఔ౓ͷ࣮૷͚ͩͰߏΘͳ͍ɻ ‣ ϦϑΝΫλϦϯά࣮૷Λݟ௚͢ɻςετΛ੒ޭͤ͞ΔͨΊʹ΍Β͔ͨ͠࿛᤻ͷ

    ਺ʑΛ͖Ε͍ʹ૟আ͠Α͏ɻॏෳΛऔΓআ͘ɻແବΛল͘ɻҙਤΛ͸͖ͬΓ͞ ͤΔɻग़དྷΔݶΓ໌ྎͰ෼͔Γ΍͍͢ίʔυʹ͠Α͏ɻ ΞδϟΠϧαϜϥΠୈষςετۦಈ։ൃ
  15. 5%%ͷαΠΫϧ 1.࣍ͷ໨ඪΛߟ͑Δ 2.ͦͷ໨ඪΛࣔ͢ςετΛॻ͘ 3.ͦͷςετΛ࣮ߦࣦͯ͠ഊͤ͞Δ 3FE  4.໨తͷίʔυΛॻ͘ 5.Ͱॻ͍ͨςετΛ੒ޭͤ͞Δ (SFFO 

    6.ςετ͕௨Δ··ͰϦϑΝΫλϦϯάΛߦ ͏ 3FGBDUPS  7.̍ʙΛ܁Γฦ͢ t-wada: says
  16. ͖Ε͍ Ԛ͍ (͙͢ʹ͸)ಈ͔ͳ͍ ಈ࡞͢Δ Red Green Refactoring 5%%ͱԫۚͷճస t-wada: says

  17. ͓୊ ࣌ܭΦϒδΣΫτ

  18. ‣ ςεςΟϯάϑϨʔϜϫʔΫ΍
 ͦͷଞ؀ڥ͸ͪΌΜͱಈ͔͘ ࠷ॳͷ໨ඪΛߟ͑Δ 

  19. $ vim spec/tokei_spec.rb ``` describe '時計' do specify { expect(true).to

    be true } end ``` ``` $ bundle exec rspec . Finished in 0.00097 seconds (files took 0.09778 seconds to load) 1 example, 0 failures ``` ࠷ॳͷҰา 
  20. ‣ RSpec͕ͪΌΜͱΠϯετʔϧ
 Ͱ͖ͯɺಈ͍͍ͯΔ ղফͰ͖ͨෆ҆ 

  21. ‣ ࣌ɺ෼ɺඵΛ࣋ͭ ‣ ʮ10࣌20෼0ඵʯͳͲɺಛఆͷ࣌ࠁΛද͢ ‣ ೔෇ͱ߹ΘͤΔ͜ͱͰɺಛఆͷ࣌ؒΛࢦ͢ ࣌ܭΦϒδΣΫτͷ࢓༷Λߟ͑Δ 

  22. ‣ Ϩου৽͍͠ίʔυΛॻ͘લʹɺ·ͣ͸ࣦഊ͢ΔϢ χοτςετΛॻ͘ɻ৽͍͠ίʔυͷҙਤΛςετ Ͱࣔ͢ΜͩɻϨου͸ઃܭʹ͍͔ͭͯͬ͠Γߟ͑Δ ग़ൃ఺ͩɻ ΞδϟΠϧαϜϥΠୈষςετۦಈ։ൃ

  23. ‣ ʮ࣌ܭΫϥεʯͷΫϥε໊͸Ͳ͏͠Α͏? ‣ Tokei ..? ‣ Clock ? ‣ etc..

    ࣍ͷ໨ඪΛߟ͑Δ 
  24. ``` describe Clock do specify { expect(Clock.new).to be_an_instance_of(Clock) } end

    ``` $ bundle exec rspec spec bundler: failed to load command: rspec 
 (/opt/brew/opt/rbenv/versions/2.3.0/bin/rspec) NameError: uninitialized constant Clock ClockΫϥεΛ࡞Γ͍ͨ → ·ͩͳ͍͔ΒΤϥʔʹͳΔ͸ͣ 
  25. ‣ ະॳظԽͷఆ਺ClockΛࢀরͨ͠Αɺͱ͍͏Τϥʔ ‣ → ·ͩͳ͍͔ΒΤϥʔʹͳΔ͸ͣ
 ظ଴௨Γͷཧ༝Ͱͷςετࣦഊ ClockΫϥεΛ࡞Δ४උ 

  26. ‣ ςετ͕ظ଴௨Γʹࣦഊ͢Δ͜ͱΛ֬ೝ͢Δͷ͸ͱ ͯ΋େࣄɻ ‣ ݟ౰͸ͣΕͷ໰୊Ͱ೰Ή͜ͱ͕͋Δɻ ‣ eg: SyntaxErrorΛݟམͱͨ͠··ClockΫϥεΛ
 ࣮૷ͯ͠΋ద੾ͳϑΟʔυόοΫʹͳΒͳ͍ ظ଴௨Γͷཧ༝Ͱͷςετͷࣦഊ

    
  27. $ mkdir lib $ vim lib/clock.rb ``` class Clock end

    ``` $ bundle exec rspec spec bundler: failed to load command: rspec 
 (/opt/brew/opt/rbenv/versions/2.3.0/bin/rspec) NameError: uninitialized constant Clock ClockΫϥεΛ࡞Δ → ಡΈࠐ·ͳ͍ͱࢀরͰ͖ͳ͍ͷ͸มΘΒͳ͍͸ͣ 
  28. ‣ҙਤͱ߹͍ͬͯΔ? ‣`require`͍ͯ͠ͳ͍͔ΒࢀরͰ͖ͳ͍ ‣→ okΆ͍ ςετࣦഊͷཧ༝Λ֬ೝ͢Δ 

  29. ``` require 'clock' describe Clock do specify { expect(Clock.new).to be_an_instance_of(Clock)

    } end ``` $ bundle exec rspec spec . Finished in 0.00462 seconds (files took 0.09435 seconds to load) 1 example, 0 failures require΋ͨ͠ˠ͜ΜͲͦ͜௨Δ͸ͣ 
  30. ‣ ϓϩμΫτίʔυͱςετίʔυΛɺͦΕͧΕ
 Ͳ͜ʹॻ͚͹Α͍ͷ͔͕Θ͔ͬͨ ‣ ϓϩμΫτίʔυ͸ lib/clock.rb ‣ ςετίʔυ͸ spec/clock_spec.rb ղফͰ͖ͨෆ҆

    
  31. ςετʹಋ͔Ε࣮ͯ૷͢Δɺ ͨΊʹ࢓༷Λཧղ͢Δ

  32. ‣ ࣌ɺ෼ɺඵΛ࣋ͭ ‣ ʮ10࣌20෼0ඵʯͳͲɺಛఆͷ࣌ࠁΛද͢ ‣ ೔෇ͱ߹ΘͤΔ͜ͱͰɺಛఆͷ࣌ؒΛࢦ͢ ࣌ܭΦϒδΣΫτͷ࢓༷Λߟ͑Δ 

  33. ࣌ɺ෼ɺඵΛ࣋ͭ

  34. ‣ ࣌ɺ෼ɺඵΛ༩͑ͯΠϯελϯε࡞Δ͜ͱ͕Ͱ͖Δ ‣ Πϯελϯεੜ੒࣌ʹ༩͑ͨ࣌ɺ෼ɺඵΛɺ
 ͦΕͧΕऔಘͰ͖Δ ‣ ࣌ܭͱͯ͠ෆద੾ͳύϥϝʔλΛ༩͑ͨ৔߹ʹ͸ɺΤϥʔ ͱ͢Δ͜ͱ ࣌ɺ෼ɺඵΛ࣋ͭ 

  35. ‣ 10࣌20෼0ඵͱ͍͏ύϥϝʔλΛ༩͑ͯɺClockΫϥεͷ
 ΠϯελϯεΛੜ੒Ͱ͖Δɻ ‣ ੜ੒ͨ͠Πϯελϯεͷʮ࣌ʯ͸10Ͱ͋Δɻ ΠϯελϯεΛͭͬͯ͘ɺ༩͑ͨ࣌෼ඵΛऔಘͰ͖Δ 

  36. ‣ 10࣌20෼0ඵͱ͍͏ύϥϝʔλΛ༩͑ͯɺClockΫϥεͷΠ ϯελϯεΛੜ੒Ͱ͖Δ ‣ ίϯετϥΫλͰɺ࣌ɺ෼ɺඵΛ༩͑Ε͹Α͍? ‣ ੜ੒ͨ͠Πϯελϯεͷʮ࣌ʯ͸10Ͱ͋Δ ‣ ήολʔ͕͋Ε͹Αͦ͞͏ ‣

    ηολʔ͸? ݟ͍͑ͯΔݶΓ͸ෆཁͦ͏ ࣍ͷ໨ඪΛߟ͑Δ 
  37. --- a/spec/clock_spec.rb +++ b/spec/clock_spec.rb @@ -2,4 +2,10 @@ require 'clock'

    describe Clock do specify { expect(Clock).to be } + + context 'new(10, 20, 00)' do + let(:clock) { Clock.new(10, 20, 0) } + + specify { expect(clock.hour).to eq(10) } + end end ΠϯελϯεΛੜ੒͢Δςετ 
  38. $ bundle exec rspec .F Failures: 1) Clock new(10, 20,

    00) Failure/Error: let(:clock) { Clock.new(10, 20, 0) } ArgumentError: wrong number of arguments (given 3, expected 0) # ./spec/clock_spec.rb:7:in `initialize' # ./spec/clock_spec.rb:7:in `new' # ./spec/clock_spec.rb:7:in `block (3 levels) in <top (required)>' # ./spec/clock_spec.rb:9:in `block (3 levels) in <top (required)>' Finished in 0.00186 seconds (files took 0.08364 seconds to load) 2 examples, 1 failure Failed examples: rspec ./spec/clock_spec.rb:9 # Clock new(10, 20, 00) ੜ੒͢ΔςετˠίϯετϥΫλҾ਺͕ҧࣦͬͯഊ͢Δ͸ͣ 
  39. ‣ άϦʔϯͱʹ͔͘ςετʹ੒ޭ͢ΔίʔυΛॻ͘ɻ ࣮૷ͷ࠷ऴܗΛࢥ͍ඳ͚ΔͳΒҰؾʹ࢓্͛ͯ͠· ͑͹͍͍ɻͦ͜·Ͱͷࣗ৴͕ͳ͚Ε͹ɺ·ͣ͸ςε τʹ੒ޭ͢Δఔ౓ͷ࣮૷͚ͩͰߏΘͳ͍ɻ ΞδϟΠϧαϜϥΠୈষςετۦಈ։ൃ

  40. Ծ࣮૷
 (Fake it)

  41. ``` --- a/lib/clock.rb +++ b/lib/clock.rb @@ -1,2 +1,8 @@ class

    Clock + def initialize(*args) + end + + def hour + 10 + end end ``` Ծ࣮૷ (Fake it) 
  42. ‣ ΦϒδΣΫτͷར༻ऀͱͯ͠ظ଴͢Δ
 ৼΔ෣͍ΛɺςετίʔυͰදݱͰ͖ͨ ‣ ҙਤͨ͠ͱ͓ΓʹΤϥʔʹͳͬͨ = ςετίʔυ͸ؒҧ͍ͬͯͳͦ͏ ‣ ଈ஋Λฦͤ͹௨ͬͨ =

    ·͢·͢Αͦ͞͏ ‣ ͜ΕΛ*ͪΌΜͱ*௨ͦ͏ ղফͰ͖ͨෆ҆ 
  43. ࡾ֯ଌྔ
 (Triangulation)

  44. --- a/spec/clock_spec.rb +++ b/spec/clock_spec.rb @@ -8,4 +8,10 @@ describe Clock

    do specify { expect(clock.hour).to eq(10) } end + + context 'new(12, 30, 00)' do + let(:clock) { Clock.new(12, 30, 0) } + + specify { expect(clock.hour).to eq(12) } + end end ࡾ֯ଌྔ (Triangulation) 
  45. ‣ άϦʔϯͱʹ͔͘ςετʹ੒ޭ͢ΔίʔυΛॻ͘ɻ ࣮૷ͷ࠷ऴܗΛࢥ͍ඳ͚ΔͳΒҰؾʹ࢓্͛ͯ͠· ͑͹͍͍ɻͦ͜·Ͱͷࣗ৴͕ͳ͚Ε͹ɺ·ͣ͸ςε τʹ੒ޭ͢Δఔ౓ͷ࣮૷͚ͩͰߏΘͳ͍ɻ ΞδϟΠϧαϜϥΠୈষςετۦಈ։ൃ

  46. --- a/lib/clock.rb +++ b/lib/clock.rb @@ -1,8 +1,9 @@ class Clock

    - def initialize(*args) + def initialize(hour, *) + @hour = hour end def hour - 10 + @hour end end 12:30ͷςετΛ௨͢Α͏ͳɺ࠷௿ݶͷ࣮૷ 
  47. ‣ ࠷ॳʹॻ͍ͨςετΛύεͤͨ͞··
 ࣍ͷςετ΋௨͢ɻ ‣ ࣗ෼ͷॻ͍ͨίʔυͱ͋Θͤͯͷ3఺Ͱɺ
 ಄ͷதͷίʔυͱɺ࣮૷ͷڑ཭ΛଌΔɻ ࡾ֯ଌྔ (Triangulation) 

  48. ‣ [done] 10࣌20෼0ඵͱ͍͏ύϥϝʔλΛ༩͑ͯɺ ClockΫϥεͷΠϯελϯεΛੜ੒Ͱ͖Δ ‣ [done] ੜ੒ͨ͠Πϯελϯεͷʮ࣌ʯ͸10Ͱ͋Δ ղফͰ͖ͨෆ҆ 

  49. ʮಈ࡞͢Δ͖Ε͍ͳίʔυʯɺϩϯɾδΣϑϦʔ ζͷ͜ͷ؆ܿͳݴ༿͸ɺ5%% ςετۦಈ։ൃ ͷ ໨ඪͰ͋Δɻಈ࡞͢Δ͖Ε͍ͳίʔυ͸ɺ͋ΒΏ Δཧ༝ͰՁ஋͕͋Δɻ ᴷ,FOU#FDL

  50. ‣ ϦϑΝΫλϦϯά࣮૷Λݟ௚͢ɻςετΛ੒ޭͤ͞ΔͨΊ ʹ΍Β͔ͨ͠࿛᤻ͷ਺ʑΛ͖Ε͍ʹ૟আ͠Α͏ɻॏෳΛऔ Γআ͘ɻແବΛল͘ɻҙਤΛ͸͖ͬΓͤ͞Δɻग़དྷΔݶΓ ໌ྎͰ෼͔Γ΍͍͢ίʔυʹ͠Α͏ɻ ΞδϟΠϧαϜϥΠୈষςετۦಈ։ൃ

  51. ‣ ςετ͕௨Δ··ͰϦϑΝΫλϦϯάΛߦ͏ ‣ ʮάϦʔϯ to άϦʔϯʯͱ͍͏ݴ͍ճ͠ {ಈ࡞͢Δ && ͖Ε͍ͳ}ίʔυΛ໨ࢦͯ͠ 

  52. --- a/lib/clock.rb +++ b/lib/clock.rb @@ -1,9 +1,8 @@ class Clock

    + attr_reader :hour + def initialize(hour, *) @hour = hour end - def hour - @hour - end end {ಈ࡞͢Δ && ͖Ε͍ͳ}ίʔυΛ໨ࢦͯ͠ 
  53. --- a/spec/clock_spec.rb +++ b/spec/clock_spec.rb @@ -1,8 +1,6 @@ require 'clock'

    describe Clock do - specify { expect(Clock.new).to be_an_instance_of(Clock) } - context 'new(10, 20, 00)' do let(:clock) { Clock.new(10, 20, 0) } ςετίʔυ΋ϦϑΝΫλϦϯά͢Δ 
  54. ‣ ςετίʔυ͸ϕλʹॻ͔͘ɺDRY-nessΛอ͔ͭ ͸ٞ࿦͕෼͔Ε͍͕ͯͨɺ͍·ͷ਼੎͸ɺςετίʔ υ΋ʮίʔυʯͳͷͰͪΌΜͱॻ͘ͱ͍͏΋ͷ ‣ ॏෳ΍แؚʹΑΔՁ஋ͷ௿͍ςετίʔυ͸מΓࠐ ΜͰ͍͘ ‣ ͨͩמΓ͗ͯ͢ɺ֊ஈ͕ٸʹͳΓ͗͢Δͷ΋ྑ͘ͳ͍ FYI:

    ΩϨΠͳίʔυ 
  55. ‣ 10࣌20෼0ඵͱ͍͏ύϥϝʔλΛ༩͑ͯɺClockΫϥεͷΠ ϯελϯεΛੜ੒Ͱ͖Δ ‣ ίϯετϥΫλͰɺ࣌ɺ෼ɺඵΛ༩͑Ε͹Α͍? ‣ ੜ੒ͨ͠Πϯελϯεͷʮ࣌ʯ͸10Ͱ͋Δ ‣ ෼͸20Ͱ͋Δɻ ‣

    ඵ͸0Ͱ͋Δɻ ࣍ͷ໨ඪΛߟ͑Δ 
  56. --- a/spec/clock_spec.rb +++ b/spec/clock_spec.rb @@ -5,6 +5,8 @@ describe Clock

    do let(:clock) { Clock.new(10, 20, 0) } specify { expect(clock.hour).to eq(10) } + specify { expect(clock.min).to eq(20) } + specify { expect(clock.sec).to eq(0) } end context 'new(12, 30, 00)' do ෼ͱඵʹର͢Δςετˠ#hour, #minϝιου͕ͳ͍ͷͰࣦഊ͢Δ͸ͣ 
  57. ‣ άϦʔϯͱʹ͔͘ςετʹ੒ޭ͢ΔίʔυΛॻ͘ɻ ࣮૷ͷ࠷ऴܗΛࢥ͍ඳ͚ΔͳΒҰؾʹ࢓্͛ͯ͠· ͑͹͍͍ɻͦ͜·Ͱͷࣗ৴͕ͳ͚Ε͹ɺ·ͣ͸ςε τʹ੒ޭ͢Δఔ౓ͷ࣮૷͚ͩͰߏΘͳ͍ɻ ΞδϟΠϧαϜϥΠୈষςετۦಈ։ൃ

  58. ໌നͳ࣮૷ 0CWJPVT *NQMFNFOUBUJPO

  59. --- a/lib/clock.rb +++ b/lib/clock.rb @@ -1,8 +1,10 @@ class Clock

    - attr_reader :hour + attr_reader :hour, :min, :sec - def initialize(hour, *) + def initialize(hour, min, sec) @hour = hour + @min = min + @sec = sec end end ໌നͳ࣮૷ (Obvious Implementation) 
  60. ‣ [done] 10࣌20෼0ඵͱ͍͏ύϥϝʔλΛ༩͑ͯɺClockΫ ϥεͷΠϯελϯεΛੜ੒Ͱ͖Δ ‣ [done] ੜ੒ͨ͠Πϯελϯεͷʮ࣌ʯ͸10Ͱ͋Δ ‣ [done] ʮ෼ʯ͸20Ͱ͋Γɺʮඵʯ͸0Ͱ͋Δ

    ղফͰ͖ͨෆ҆ 
  61. ೔෇ͱ߹ΘͤΔ͜ͱͰɺ ಛఆͷ࣌ؒΛࢦ͢

  62. ‣ ࣍ͷ೔࣌ɺલͷ೔࣌Λಋग़Ͱ͖Δ ‣ ͖ΐ͏ͷʮ10:20ʯ͸͍͔ͭ ‣ 2017-08-08T10:20:00+JST ೔෇ͱ߹ΘͤΔ͜ͱͰɺಛఆͷ࣌ؒΛࢦ͢ 

  63. --- a/spec/clock_spec.rb +++ b/spec/clock_spec.rb @@ -22,4 +22,11 @@ describe Clock

    do + + describe '#to_time' do + let(:clock) { Clock.new(10, 20, 0) } + let(:time) { clock.to_time(Date.today) } + + specify { + expect(time.iso8601).to eq ‘2017-08-08T10:20:00+09:00' + } + end end APIΛߟ͑Δ #to_time(<#Date>)͕ૉ௚ͦ͏ˠ#to_timeͷ࣮૷ͳ͍ 
  64. --- a/lib/clock.rb +++ b/lib/clock.rb @@ -7,6 +7,10 @@ class Clock

    @sec = varify_valid_clock_input(sec, 60) end + def to_time(date) + Time.local(2017, 8, 8, 10, 20) + end + private def varify_valid_clock_input(val, max) ճ౴ྫ: Ծ࣮૷ 
  65. ‣ ೔෇ͱ߹ΘͤΔ͜ͱͰɺಛఆͷ࣌ؒΛࢦ͢ ‣ ຊ೔ͷɺ10:20Λදݱ͢Δ ‣ 8/1ͷɺ10:20Λදݱ͢Δ ࡾ֯ଌྔ 

  66. ‣ ࣍ͷ೔࣌ɺલͷ೔࣌Λಋग़Ͱ͖Δ ‣ ͖ΐ͏ͷ 10:20 ͸ 2017-08-08T10:20:00 JST ‣ 8/1ͷ

    10:20 ͸ 2017-08-01T10:20:00 JST ࡾ֯ଌྔͷexampleΛ۩ମԽ 
  67. --- a/spec/clock_spec.rb +++ b/spec/clock_spec.rb @@ -25,8 +25,16 @@ describe Clock

    do describe '#to_time' do let(:clock) { Clock.new(10, 20, 0) } - let(:time) { clock.to_time(Date.today) } + context '(Date.today)' do + let(:time) { clock.to_time(Date.today) } - specify { expect(time.iso8601).to eq '2017-08-08T10:20:00+09:00' } + specify { expect(time.iso8601).to eq '2017-08-08T10:20:00+09:00' } + end + + context '(2017-08-01)' do + let(:time) { clock.to_time(Date.new(2017, 8, 1)) } + + specify { expect(time.iso8601).to eq '2017-08-08T10:20:00+09:00' } + end end end ࡾ֯ଌྔ 
  68. --- a/lib/clock.rb +++ b/lib/clock.rb @@ -8,7 +8,7 @@ class Clock

    end def to_time(date) - Time.local(2017, 8, 8, 10, 20) + Time.local(date.year, date.month, date.day, @hour, @min, @sec) end private ࡾ֯ଌྔ 
  69. --- a/spec/clock_spec.rb +++ b/spec/clock_spec.rb @@ -26,7 +26,7 @@ describe Clock

    do describe '#to_time' do let(:clock) { Clock.new(10, 20, 0) } context '(Date.today)' do - let(:time) { clock.to_time(Date.today) } + let(:time) { clock.to_time(Date.new(2017, 8, 8)) } specify { expect(time.iso8601).to eq '2017-08-08T10:20:00+09:0 end ςετίʔυͷվળ: ֎෦ґଘ஋Λແ͘͢ 
  70. ‣ 5%%͸ϓϩάϥϛϯάதͷઃܭ൑அͱϑΟʔυόοΫͷؒ ʹ͋ΔΪϟοϓΛೝࣝ͢Δ͜ͱͰ͋ΓɺͦͷΪϟοϓΛί ϯτϩʔϧ͢Δٕ๏Ͱ΋͋Δɻ ςετۦಈ։ൃೖ໳  ‣ ద੾ͳϑΟʔυόοΫΛಘଓ͚ΔΔͨΊʹେࣄͳ΋ͷ ‣ Repeatable:

    ͍࣮ͭߦͯ͠΋ಉ݁͡ՌʹͳΔ͜ͱ ‣ Independent: ଞͷςετέʔεʹґଘ͠ͳ͍͜ͱ Α͍ςετίʔυͱ͸ 
  71. ‣ Q1. https://ghe.example.com/moro/emoji_renderer Λ
 ࣗ෼ͷϦϙδτϦͱͯ͠ fork ͠ɺͦΕΛclone͠ͳ͍͞ ‣ Q2. `17day`

    ϒϥϯνΛ࡞੒͠ͳ͍͞ ࣮श 
  72. ‣ ͜͜·Ͱͷ࣭໰͕͋Ε͹࣮श͠ͳ͕ΒखΛ
 ڍ͍͛ͯͩ͘͞! ࣭ٙλΠϜ 

  73. ‣ Q3. `hello :innocent:` Λ `hello `ʹม׵͢Δ
 ϓϩάϥϜΛTDDͰ࣮૷͠ͳ͍͞ɻ ‣ 3-1.

    ΠϯλʔϑΣʔεΛఆٛ͢ΔͷΈͷࣦഊ͢ΔςετΛ࡞੒͠ɺίϛοτ͠ͳ͍͞ ‣ 3-2. 3-1ͷςετ͕௨ΔΑ͏ͳԾ࣮૷Λ௥Ճ͠ɺίϛοτ͠ͳ͍͞ ‣ 3-3. `hello :sunglasses:` Λ `hello ` ʹ͢Δࡾ֯ଌྔͷςετΛ௥Ճ͠ɺίϛοτ͠ͳ͍͞ ‣ 3-4. 3-1, 3-3྆ํͷςετ͕௨ΔΑ͏ʹ࣮૷͠ίϛοτ͠ͳ͍͞ ‣ ώϯτ: ͸ "\u{1f607}" ͸ "\u{1f60e}" ͰදࣔͰ͖·͢ ‣ ίϛοτϝοηʔδʹ͸ʮ3-xʯͷΑ͏ͳ൪߸Λ;͘Ί͍ͯͩ͘͞ɻ ࣮श 
  74. ‣ Q4. `hello :innocent: :sunglasses:` Λ `hello `ʹ
 ม׵͢ΔϓϩάϥϜΛTDDͰ࣮૷͠ͳ͍͞ɻ ‣

    4-1a. ࣗ৴͕͋Δ৔߹͸ɺҰؾʹ໌֬ͳ࣮૷Λ͠ɺίϛοτ͠ͳ͍͞ ‣ 4-1b. ࣗ৴͕ͳ͍৔߹ɺࣦഊ͢ΔςετɺԾ࣮૷ɺࡾ֯ଌྔͷςετΛ௥Ճ͠ɺίϛοτ͠ͳ͍͞ ࣮श 
  75. ‣ Q5. gemoji gem Λ࢖͍ɺม׵ίʔυΛϦϑΝΫλϦϯά ͠ͳ͍͞ ‣ https://github.com/github/gemoji ‣ 5-1.

    ςετίʔυͷมߋ͸ͤͣɺϓϩμΫτίʔυͷΈमਖ਼͠ͳ͍͞ɻ ࣮श 
  76. ‣ Q6. ม׵ίʔυΛ֦ு͠ɺ֦ுUnicodeͰ͸ͳ͘
 <img>λάΛग़ྗ͢Δ͜ͱʮ΋ʯՄೳʹ͠ͳ͍͞ɻ ‣ 期待する出力 "hello <img src=unicode/1f607.png />"

    ‣ 6-1. ग़ྗΛ੾Γସ͑ΔΠϯλʔϑΣʔεΛઃܭ͠ɺࣦഊ͢ΔςετΛ௥Ճ͠ɺίϛοτ͠ͳ͍͞ɻ ‣ 6-2. ϓϩμΫτίʔυΛ࣮૷͠ɺίϛοτ͠ͳ͍͞ɻ ࣮श 
  77. ‣ Qn. ୡ੒Ͱ͖ͨίʔυΛforkͨࣗ͠ϦϙδτϦʹpush͠ɺ
 moro/emoji_renderer ΁PRΛૹΓͳ͍͞ ‣ descriptionʹ޻෉ͨ͠఺΍ײ૝Λॻ͍͍ͯͩ͘͞ ࣮श 

  78. ͓ർΕ͞·Ͱͨ͠