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

RSpec 勉強会

RSpec 勉強会

Tnishikori

August 08, 2017
Tweet

More Decks by Tnishikori

Other Decks in Technology

Transcript

  1. 3 4 1 & $ ษ ڧ ձ 1

  2. * O E F Y Y6OJUPSY4QFD  34QFDͷ֓ཁ 34QFD֦ு 'BDUPSZ(JSMͷ֓ཁ

    ࢀߟจݙ 2
  3. Y 6 O J U   P S 

     Y 4 Q F D 3
  4. Y 6 O J U ܥ ͱ Y 4 Q

    F D ܥ 4 xUnit xSpec ίϯηϓτ ςετͷظ଴஋ΛಘΔ ͦͷػೳͷৼΔ෣͍͸Ͳ͏Ώ͏ ΋ͷ͔ ॻ͖ํ ؔ਺ɺϝιουͷΑ͏ͳॻ͖ ํ %4-Λ࠾༻͍ͯ͠Δ͜ͱ͕ଟ͍ ֶशίετ ௿͍ ߴ͍ Մಡੑ ಡΈͮΒ͍ ಡΈ΍͍͢
  5. ॻ ͖ ํ ͷ ҧ ͍ lGJ[[zΛฦ͢ϝιουͱzCV[[zΛฦ͢ϝιουΛ࣋ͭ 'J[[#V[[Ϋϥεͷྫ 5

  6. ' J Y U V S F T ͱ '

    B D U P S Z ( J S M 'JYUVSFT ZNMϑΝΠϧʹϨίʔυͮͭॻ͘ 'BDUPSZ(JSMʹൺ΂Δͱ࣮ߦ଎౓͸ૣ͍ 7BMJEBUJPO͸௨Βͳ͍ ΧϥϜ͕૿͑Δͱશ෦ͷϨίʔυΛॻ͖௚͕͠ൃੜ 'BDUPSZ(JSM ιʔείʔυʹςετσʔλΛهࡌ 7BMJEBUJPO͕௨Δ ֶशίετ͕ߴ͍ ຖճ7BMJEBUJPOΛ௨͢ͱ஗͍ 6
  7. 3 4 Q F D ͷ ֓ ཁ 7

  8. 3 4 Q F D ͱ ͸ ϓϩάϥϜͷৼΔ෣͍ #FIBWJPVS Λهड़͢ΔͨΊͷ%4-Λ

    ఏڙ͢ΔϑϨʔϜϫʔΫ ϓϩάϥϜΛॻ͘લʹৼΔ෣͍Λॻ͘#%% ৼ෣ۦಈ։ ൃ Λڧ͘ҙࣝ #%%ͷ໨త͸ɺͦͷιϑτ΢ΣΞ͕࢖ΘΕΔঢ়گΛઆ໌͢ ΔͨΊͷݴޠΛ୯७Խ͢Δ͜ͱͰίϛϡχέʔγϣϯΛޙ ԡ͢͠Δ͜ͱ
 
 8 Given When Then
  9. ج ຊ త ͳ ࢖ ͍ ํ ϑΝΠϧ໊͸ @TQFDSC TQFDҎԼʹςετίʔυΛ௥Ճ͍ͯ͘͠

    STQFDϑΝΠϧ໊Ͱ࣮ߦ DPWBSBJMT౳ͱ૊Έ߹ΘͤΔͱΧόϨοδΛදࣔ͢Δ͜ͱ΋ Ͱ͖Δ STQFDϑΝΠϧʹSTQFDίϚϯυͷΦϓγϣϯΛॻ͍͓ͯ͘ ͜ͱ΋ग़དྷΔ 9
  10. 3 4 Q F D ͷ ॻ ࣜ EFTDSJCFςετͷର৅ɺઆ໌ Ϋϥε໊ɺϝιου໊Λهࡌ͢Δͱ(PPE

    DPOUFYUςετͷ৚݅ dͷ৔߹ɺdͰ͋Δ࣌ JU FYBNQMF ςετͷ಺༰ɺظ଴஋ dͰ͋Δࣄ FYQFDUର৅ͷධՁΛ͢Δ TLJQର৅ͷςετΛεΩοϓ͢Δ 10
  11. M F U ςετͷ಺෦Ͱ࢖༻Ͱ͖Δม਺ɺؔ਺తͳΠϝʔδ MFUϒϩοΫ\^Ͱهࡌ EFTDSJCF DPOUFYU಺Ͱఆٛ͠ɺJU಺Ͱݺͼग़͕͠Մೳ MFU͸஗ԆධՁͰMFU͸ଈ࠲ʹධՁ ໎ͬͨͱ͖͸MFUʹ͓ͯ͘͠ͱ҆શ 11

  12. ಉ ͡ ς ε τ Λ ά ϧ ʔ ϐ

    ϯ ά TIBSFE@FYBNQMFT@GPSͰςετίʔυΛάϧʔϐϯά ɺ JU@CFIBWFT@MJLFͰάϧʔϓΛݺͼग़͠ DPOUFYUͷάϧʔϐϯά͸TIBSFE@DPOUFYUͱJODMVEF@DPOUFYU Λ࢖͏ 12
  13. M F U   ά ϧ ʔ ϐ ϯ

    ά 4 B N Q M F 13 άϧʔϐϯάΛߦ͏લ άϧʔϐϯάޙ
  14. ς ε τ ͷ લ ॲ ཧ ͱ ޙ ॲ

    ཧ CFGPSFͰલॲཧɺBGUFSͰޙॲཧ TVJUFશςετͷ࣮ߦલޙʹҰճ BMM֤ϒϩοΫ DPOUFYUEFTDSJCF ͷલޙ FBDIશͯͷJUϒϩοΫͷલޙ 14
  15. Α ͘ ࢖ ͏ ຣ ஡ ʔ N B U

    D I F S OPU@ UPFR౳Ձ͔Ͳ͏͔ UPCF CF@FNQUZΦϒδΣΫτ͕ۭͰ͋Δ͔ CF ccc ΦϒδΣΫτʹରͯ͠ͷൺֱ CF@OJMΦϒδΣΫτ͕OJM͔Ͳ͏͔ UPJODMVEF഑ྻ಺ʹσʔλ͕͋Δ͔ 15
  16. 3 4 Q F D ֦ ு 16

  17. 3 4 Q F D ͱ ૊ Έ ߹ Θ

    ͤ Δ ͱ ศ ར STQFDSBJMT 4FMFOJVN 1PMUFSHFJTU $BQZCBSB 17
  18. 3 4 Q F D  3 B J M

    T DPOUSPMMFS UZQFDPOUSPMMFS HFUQPTUQVUEFMFUFΞΫγϣϯ໊ ύϥϝʔλ SFRVFTU UZQFSFRVFTU HFUQPTUQVUEFMFUF63- ύϥϝʔλ WJFX UZQFWJFX SFOEFSͰWJFXϨϯμϦϯά SFOEFSFEͰϨϯμϦϯάͨ͠WJFXऔಘ BTTFSU@TFMFDUΤϨϝϯτIUNMଐੑ஋ʹର͢ΔΞαʔγϣϯ 18
  19. ' B D U P S Z ( J S

    M ͷ ֓ ཁ 19
  20. ' B D U P S Z ( J S

    M ʹ ͭ ͍ ͯ ΦϒδΣΫτ͔Βఆٛͨ͠σʔλΛੜ੒ͯ͘͠ΕΔ ςετσʔλ౤ೖʹ࢖ΘΕΔ ιʔείʔυͰςετσʔλΛఆٛ͢Δ 20
  21. ' B D U P S Z ( J S

    M ͷ ఆ ٛ 21
  22. ε τ ϥ ς δ ʔ DSFBUFςετσʔλΛ࡞੒͢Δ CVJMEςετΫϥεͷ7BMJEBUJPOΛߦͬͨޙͷΠϯελϯ εΛੜ੒ͯ͠ฦ͢ TUVC7BMJEBUJPO΋ߦΘͣɺΠϯελϯεੜ੒ͷΈ

    @MJTUҰׅʹ্هͷετϥςδʔΛ࣮ߦ͢Δ 22
  23. % 4 - USBJUෳ਺ͷଐੑΛάϧʔϓԽ͠ɺGBDUPSZʹద༻ग़དྷΔ USBOTJFOUҰ࣌తͳม਺ɺBUUSJCVUFΛఆٛͰ͖ΔɻUSBJU಺ ʹωετ͢Δ͜ͱ΋Մೳ TFRVFODFT࿈൪Λੜ੒ DBMMCBDLTCFGPSF BGUFS CFGPSF

    DSFBUF CFGPSF TUVC CFGPSF CVJME  BGUFS DSFBUF BGUFS TUVC BGUFS CVJME 23
  24. 24

  25. ࢀ ߟ จ ݙ 25

  26. ࢀ ߟ จ ݙ ࢖͑Δ34QFDೖ໳ɾͦͷ IUUQRJJUBDPNKODIJUPJUFNTECED STQFDΨΠυϥΠϯ IUUQCFUUFSTQFDTPSHKQ 34QFDͷ EFTDSJCFDPOUFYUFYBNQMFJU

    ͷ࢖͍෼͚ IUUQRJJUBDPNVDIJLPJUFNTEDEGG .JOJUFTUͱ3TQFDɺ'JYUVSFTͱ'JDUPSZ(JSMͷൺֱ IUUQCMPHKOJUPDPNFOUSZ 26