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

RSpecはじめました

Ca5eecc06f8f1b8a978f3025224ff5ff?s=47 kkabetani
October 19, 2013

 RSpecはじめました

kanazawa.rb meetup #14 で行われたミニコーナー「Test ! Test !! Test !!!」で発表したスライド

Ca5eecc06f8f1b8a978f3025224ff5ff?s=128

kkabetani

October 19, 2013
Tweet

Transcript

  1. 34QFD͸͡Ί·ͨ͠  LBOB[BXBSCNFFUVQ !LLBCFUBOJ

  2. ࣗݾ঺հ w!LLBCFUBOJ w5PZBNB w+BWBͰ8FCΞϓϦ࡞ͬͯ·͢ w+BWB4DSJQUগʑ w3VCZ͸झຯͰ৮ͬͯ·͢

  3. ̏ϲ݄લ wʮͨͷ͍͠3VCZʯΛࣸܦͨ͠ w3VCZPO3BJMT΍ͬͯΈΑ͏͔ͳʔ wLBOB[BXBSCʹॳࢀՃͨ͠

  4. 34QFDͬͯԿʁ

  5. ࠷ۙ w3VCZPO3BJMTͰΞϓϦ࡞͔ͬͨΒςε τॻ͜͏ʢ࣍͸5%%Ͱ΍ͬͯΈΑ͏ʣ w(FN࡞ͬͯΈΑ͏ w%4-ʁԿͦΕʁ໘നͦ͏ wLBOB[BXBSCʹࢀՃָͯ͘͠͠ͳͬͯ ͖ͨ

  6. 34QFDͪΐͬͱ ෼͔͖ͬͯͨ

  7. ͦΜͳࣗ෼͕ 34QFDͰษڧ͖ͯ͠ ͨ͜ͱΛൃද͠·͢

  8. 34QFDͱͷग़ձ͍ w3VCZPO3BJMTνϡʔτϦΞϧͰࣸ ܦͯ͠ษڧͯͨ͠ͱ͖ 3BJMTW wIUUQSBJMTUVUPSJBMKQ

  9. ࠷ॳʹॻ͍ͨ34QFD require 'spec_helper' describe "Static pages" do describe "Home page"

    do it "should have the content 'Sample App'" do visit '/static_pages/home' page.should have_content('Sample App') end end end
  10. ࠷ॳʹॻ͍ͨ34QFD require 'spec_helper' describe "Static pages" do describe "Home page"

    do it "should have the content 'Sample App'" do visit '/static_pages/home' page.should have_content('Sample App') end end end
  11. ࠷ॳʹॻ͍ͨ34QFD require 'spec_helper' describe "Static pages" do describe "Home page"

    do it "should have the content 'Sample App'" do visit '/static_pages/home' page.should have_content('Sample App') end end end
  12. ϯʁφχίϨʁ w3VCZͬΆ͍͚Ͳ w͜Μͳͷशͬͯͳ͍Μ͚ͩͲ wEFTDSJCF wJU wϒϩοΫʁ

  13. ࠷ॳ͸ͱʹ͔ࣸ͘ܦ͠ ͯಈ͖ΛݟͯΔ͚ͩ

  14. ࣦഊͯ͠ΔͶ

  15. ·ͨࣸܦͯ͠࠶࣮ߦ

  16. ੒ޭͨ͠Ͷ

  17. ࣸܦΛ܁Γฦͨ݁͠Ռ wগͮͭ͠34QFDͷ֓ཁ͕෼͔͖ͬͯͨ wSBJMTͷಈ͖Λॻ͍ͯςετͯ͠Δͩͳ

  18. ٙ໰΋ͨ͘͞Μग़͖ͯͨ

  19. ٙ໰ wͰ΋ɺ͜ΕͲ͏͍͏ಈ͖ʹͳͬͯΔ ͷʁ w3VCZͳͷʁ wEFTDSJCFͱ͔JUͱ͔·ͩΑ͘෼͔ͬ ͯͳ͍Μ͚ͩͲ

  20. ͦΜͳͱ͖

  21. LBOB[BXBSC w!:VLJNJUTV@*[BXB͞Μͷൃද w3VCZͰ࡞Δ%4- wIUUQXXXTMJEFTIBSFOFU ZJ[BXBSVCZETM

  22. LBOB[BXBSC w34QFD͸3VCZͰ࣮૷͞Εͨ಺෦ %4- w؆୯ͳίʔυͰ%4-Λઆ໌͍ͯͨͩ͠ ͘

  23. %4-ʂʁ

  24. ͋ʂ34QFD΋ϒϩο Ϋ౉ͯ͠Δͷ͔΋

  25. 3VCZPO3BJMT͸ ͪΐͬͱஔ͍ͱ͍ͯɺ 34QFD %4- ͷษڧ͠ ͯΈΑ͏

  26. 34QFDͱ͸Կ͔ʁ wϓϩάϥϜͷৼ෣ CFIBWJPVS Λه ड़͢ΔͨΊͷυϝΠϯಛԽݴޠ %PNBJO4QFDJpD -BOHVBHF%4- Λఏڙ͢ΔϑϨʔ ϜϫʔΫ

  27. ΍ͬͺΓʂ %4-ͳͷ͔ʂʂ

  28. ιʔεಡΜͰΈΑ͏ w͖ͬͱEFTDSJCFؔ਺ͰϒϩοΫΛҾ ਺ʹͯ͠Δͱ͜Ζ͕͋Δ͸ͣ wEFTDSJCFͰͻͨ͢Β୳͢

  29. ιʔεಡΜͰΈΑ͏ rspec-core/lib/spec/core/dsl.rb def describe(*args, &example_group_block) RSpec::Core::ExampleGroup.describe(*args, &example_group_block).register end

  30. ιʔεಡΜͰΈΑ͏ rspec-core/lib/spec/core/dsl.rb def describe(*args, &example_group_block) RSpec::Core::ExampleGroup.describe(*args, &example_group_block).register end

  31. ιʔεಡΜͰΈΑ͏ wEFTDSJCFؔ਺ݟ͚ͭͨ wҾ਺ͰϒϩοΫ౉ͯ͠Δ w͕͜͜34QFDͷग़ൃ఺ w%4-͕֬ೝग़དྷͨ

  32. ෼͔͖ͬͯͨ describe Bowling, "#score" do it "returns 0 for all

    gutter game" do bowling = Bowling.new 20.times { bowling.hit(0)} bowling.score.should eq(0) end end
  33. ෼͔͖ͬͯͨ describe Bowling, "#score" do it "returns 0 for all

    gutter game" do bowling = Bowling.new 20.times { bowling.hit(0)} bowling.score.should eq(0) end end
  34. ෼͔͖ͬͯͨ describe Bowling, "#score" do it "returns 0 for all

    gutter game" do bowling = Bowling.new 20.times { bowling.hit(0)} bowling.score.should eq(0) end end
  35. ෼͔͖ͬͯͨ wιʔεΛಡΉ͜ͱͰɺEFTDSJCF͕Կ ͯ͠Δ͔෼͔ͬͨ wJU΋Կͯ͠Δ͔෼͔ͬͨ

  36. ·ͱΊ w࠷ॳ͸34QFD࢖͚ͬͯͨͲɺશવͪΜ ΀Μ͔Μ΀Μͳঢ়ଶ w%4-Λ஌͔ͬͯΒɺ%4-ʹ͍ͭͯ΋ͬ ͱ஌Γͨ͘ͳͬͨ

  37. ·ͱΊ wͪΐ͏Ͳͦͷ࣌ɺݟͯͨ34QFD͕ %4-ͩͱ͍͏͜ͱΛ஌Δ wͦΕ͔Β͸ɺ34QFDͷιʔεಡΜͩ Γɺ34QFDʹ͍ͭͯॻ͔Ε͍ͯΔهࣄ ΛಡΈ͋͞Δ w͖͔͚ͬ͸LBOB[BXBSCͩͬͨ

  38. ࣍΁ wࠓ೔Λ͖͔͚ͬʹ࣍΁ w%4- w34QFD΋ͬͱਂ͘ w3VCZPO3BJMT w#%% 5%% wωλ͸ͨ͘͞Μ͋Δ

  39. ͋Γ͕ͱ͏͍͟͝·ͨ͠