Save 37% off PRO during our Black Friday Sale! »

Introduce-my-gem-factory_strategist

 Introduce-my-gem-factory_strategist

https://kaigionrails.org/2021/ の登壇資料です

696374755aea172f74c9235387a248ab?s=128

Keiko Kaneko

October 22, 2021
Tweet

Transcript

  1. Keiko Kaneko ( @neko314 ) 2021.10.22 (Fri) Kaigi on Rails

    2021 Day1 FactoryBot ͷ build strategy Λ ͍͍ײ͡௚ͯ͘͠ΕΔ gem Λ ࡞ͬͨ࿩
  2. • ͔Ͷ͜ɹ͚͍͜ • GitHub: neko314 / Twitter: neko314_ • Asakusa.rb

    • גࣜձࣾΞϯυύου • ܹਏ͸ϥΠϑϫʔΫ • ۦ͚ग़͠؍Δক ࣗݾ঺հ
  3. • gem ͷ঺հ • ಈػ • ࣮૷ • ੒Ռ •

    ͜Ε͔Β ΞδΣϯμ
  4. ͦͷલʹగਖ਼ 🙏

  5. FactoryBot ͷ build strategy Λ͍͍ײ ͡௚ͯ͘͠ΕΔ gem Λ࡞ͬͨ࿩ ↓ FactoryBot

    ͷ build strategy Λ͍͍ײ ͡ʹڭ͑ͯ͘ΕΔ gem Λ࡞͍ͬͯΔ࿩
  6. վΊͯ…

  7. 🤖 FactoryStrategist ͷ͝঺հ🕵 https://github.com/neko314/factory_strategist

  8. FactoryStrategist ͱ͸ FactoryBot ͷ build strategy Λ ͍͍ײ͡ʹڭ͑ͯ͘ΕΔ gem

  9. σϞ $ FATORYSTRATEGIST=1 bin/rspec spec/models/user_spec.rb

  10. σϞ $ FATORYSTRATEGIST=1 bin/rspec spec/models/user_spec.rb

  11. σϞ $ FATORYSTRATEGIST=1 bin/rspec spec/models/user_spec.rb "./spec/models/user_spec.rb:4 create can be replaced

    to build" . Finished in 0.03062 seconds ( fi les took 5.47 seconds to load)1 example, 0 failures
  12. σϞ $ FATORYSTRATEGIST=1 bin/rspec spec/models/user_spec.rb "./spec/models/user_spec.rb:4 create can be replaced

    to build" . Finished in 0.03062 seconds ( fi les took 5.47 seconds to load)1 example, 0 failures
  13. ಈػͷ࿩

  14. • ςετΛ଎͍ͨ͘͠ • Ͱ͖Δָ͚ͩʹίʔυΛॻ͖͍ͨ • ςετͰ͸ʮԿΛςετ͢Δ͔ʯʹ஫ྗͯ͠ ʮͲ͏ॻ͔͘ʯʹΤωϧΪʔΛ஫͕ͳͯ͘΋ྑ ͍ͨ͘͠ ಈػ

  15. • ࡢ೥ͷ Kaigi on Rails ͷ toshimaru ͞Μͷ͓࿩ • https://speakerdeck.com/toshimaru/

    factorybot-the-right-way ಈػ - ςετΛ଎͍ͨ͘͠
  16. • "build strategies"ͱ͸ • https://github.com/thoughtbot/factory_bot/ blob/master/README.md • https://github.com/thoughtbot/factory_bot/ blob/master/GETTING_STARTED.md ಈػ

    - ςετΛ଎͍ͨ͘͠
  17. • "build strategies"ͱ͸ ಈػ - ςετΛ଎͍ͨ͘͠

  18. • build strategies • create • build • build_stubbed •

    attributes_for ಈػ - ςετΛ଎͍ͨ͘͠
  19. • build strategies • create • build • build_stubbed •

    attributes_for ಈػ - ςετΛ଎͍ͨ͘͠ ͜ΕΒΛ࢖͍෼͚͍ͨ
  20. • ࣮ࡍͷྫʢͱ͋ΔϦϙδτϦͷ User Ϟσϧʣ ಈػ - ςετΛ଎͍ͨ͘͠ create 0.945ms build

    0.001ms build_stubbed 0.004ms
  21. • ࣮ࡍͷྫʢͱ͋ΔϦϙδτϦͷ User Ϟσϧʣ ಈػ - ςετΛ଎͍ͨ͘͠ create 0.945ms build

    0.001ms build_stubbed 0.004ms
  22. • ࣮ࡍͷྫʢͱ͋ΔϦϙδτϦͷ User Ϟσϧʣ ಈػ - ςετΛ଎͍ͨ͘͠ create 0.945ms build

    0.001ms build_stubbed 0.004ms 🤔
  23. create Λ build / build_stubbed ʹ͢Δ ͜ͱͰςετΛ଎͘Ͱ͖Δ ಈػ - ςετΛ଎͍ͨ͘͠

  24. طʹ͋Δෆཁͳ create Λ΍ΊΔ ৽ͨʹෆཁͳ create Λ૿΍͞ͳ͍ ಈػ - ςετΛ଎͍ͨ͘͠

  25. طଘίʔυ΋৽نͷίʔυ΋νΣοΫͯ͠΄͍͠

  26. 💡ͦ͏͍͏ίʔυΛॻ͍ͯΈΑ͏

  27. 🤖 FactoryStrategist 🕵 https://github.com/neko314/factory_strategist

  28. ͔͜͜Β࣮૷ͷ࿩

  29. •Rails ΞϓϦͰ͋Δ͜ͱ •RSpec Λར༻͍ͯ͠Δ͜ͱ ࣮૷ - ࠓճͷલఏ

  30. 1. create ͍ͯ͠ΔςετΛͦͷ··࣮ߦ͢Δ 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠

    ͯςετΛ࣮ߦ͢Δ 3. ࠷దͳ build strategy ΛબͿ ࣮૷ - ΍Γ͍ͨॲཧ
  31. 1. create ͍ͯ͠ΔςετΛͦͷ··࣮ߦ͢Δ 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠

    ͯςετΛ࣮ߦ͢Δ 3. ࠷దͳ build strategy ΛબͿ ࣮૷ - ΍Γ͍ͨॲཧ
  32. 1. create ͍ͯ͠ΔςετΛͦͷ··࣮ߦ͢Δ -> ʮͦͷ··ʯͳͷͰಛʹ΍Δ͜ͱͳ͠ʂ ࣮૷ - ΍Γ͍ͨॲཧ

  33. 1. create ͍ͯ͠ΔςετΛͦͷ··࣮ߦ͢Δ 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠

    ͯςετΛ࣮ߦ͢Δ 3. ࠷దͳ build strategy ΛબͿ ࣮૷ - ΍Γ͍ͨॲཧ
  34. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ ࣮૷ -

    ΍Γ͍ͨॲཧ
  35. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    2.2. ςετίʔυΛมߋ࣮ͯ͠ݱ͢Δ ࣮૷ - ΍Γ͍ͨॲཧ
  36. • ෳ੡ͨ͠ϑΝΠϧΛॻ͖׵͑ͯςετ͢Δ • DB ࣗମ͔Β INSERT ͞Ε͍ͯΔ͕ SELECT ͞ Ε͍ͯͳ͍Ϩίʔυ͕ͳ͍͔Λௐ΂Δ

    ࣮૷ - ࠾༻͠ͳ͔ͬͨ͜ͱ
  37. • ෳ੡ͨ͠ϑΝΠϧΛॻ͖׵͑ͯςετ͢Δ → 😇ແݶϧʔϓ • DB ࣗମ͔Β INSERT ͞Ε͍ͯΔ͕ SELECT

    ͞ Ε͍ͯͳ͍Ϩίʔυ͕ͳ͍͔Λௐ΂Δ → ΞϓϦέʔγϣϯ͔Βͷૢ࡞͕೉͔ͬͨ͠ ❓DBͷछྨʹ΋ΑΓͦ͏ʁ ࣮૷ - ࠾༻͠ͳ͔ͬͨ͜ͱ
  38. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    2.2. ςετίʔυΛมߋ࣮ͯ͠ݱ͢Δ ࣮૷ - ΍Γ͍ͨॲཧ
  39. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    2.2. ςετίʔυΛมߋ࣮ͯ͠ݱ͢Δ ࣮૷ - ΍Γ͍ͨॲཧ
  40. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    ࣮૷ - ΍Γ͍ͨॲཧ alias_method :create, :build alias_method :create, :build_stubbed
  41. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    🙆ʮ࡞Γͳ͕ΒඞཁͳॲཧΛ੔ཧ͍ͯ͘͠ʯ ͕Ͱ͖ͨͷͰΑ͔ͬͨ ࣮૷ - ΍Γ͍ͨॲཧ alias_method :create, :build alias_method :create, :build_stubbed
  42. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    🙅1ͭ1ͭͷݕࠪ͸Ͱ͖ͳ͍ ࣮૷ - ΍Γ͍ͨॲཧ alias_method :create, :build alias_method :create, :build_stubbed
  43. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    2.2. ςετίʔυΛมߋ࣮ͯ͠ݱ͢Δ ࣮૷ - ΍Γ͍ͨॲཧ
  44. 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠ ͯςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    2.2. ςετίʔυΛมߋ࣮ͯ͠ݱ͢Δ ࣮૷ - ΍Γ͍ͨॲཧ ҰମͲ͏΍ͬͯ🤔
  45. 2. create ͷՕॴΛ build ΍ build_stubbed ʹͯ͠ ςετΛ࣮ߦ͢Δ 2.1. ςετίʔυΛมߋͤͣʹ࣮ݱ͢Δ

    2.2. ςετίʔυΛมߋ࣮ͯ͠ݱ͢Δ ϝλσʔλͱ͍ͯ࣋ͬͯ͠Δ࣮ߦ͢΂͖ςε τίʔυΛղੳͯ͠ॻ͖׵͑Δ ࣮૷ - ݁࿦
  46. …೉͍͠

  47. ✂೉͍͠໰୊͸খ͘͞෼ղ͢Δ✂

  48. • ͘͢͝γϯϓϧͳςετͰߟ͑Δ͜ͱʹ͢Δ ࣮૷ # sample_app/spec/models/user_spec.rb 1. require 'rails_helper' 2. 3.

    RSpec.describe User, type: :model do 4. it { expect(FactoryBot.create(:user)).to be_valid } 5. end
  49. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end
  50. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end ςετΛ࣮ߦ
  51. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end FactoryBotΛར༻͍ͯ͠Ε͹ create Ͱ example.run build Ͱ example.run build_stubbed Ͱ example.run Ͱςετ͕௨Δ͔Ͳ͏͔Λ͔֬ΊΔ
  52. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end ԿΛ͍ͯ͠Δͷ͔?? 🤔
  53. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end # class RSpec::Core::Example::Procsy def call(*args, &block) @executed = true @proc.call(*args, &block) end alias run call
  54. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end # class RSpec::Core::Example::Procsy def call(*args, &block) @executed = true @proc.call(*args, &block) end alias run call
  55. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end # class RSpec::Core::Example::Procsy def call(*args, &block) @executed = true @proc.call(*args, &block) end alias run call ͜ͷத਎͸?? 🤔
  56. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end example.example.metadata[:block] = > #<Proc:0 x 00007f9db0a06040 /Users/neko314/ sample_app/spec/models/user_spec.rb:4>
  57. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end example.example.metadata[:block] = > #<Proc:0 x 00007f9db0a06040 /Users/neko314/ sample_app/spec/models/user_spec.rb:4> # sample_app/spec/models/user_spec.rb 1. require 'rails_helper' 2. 3. RSpec.describe User, type: :model do 4. it { expect(FactoryBot.create(:user)).to be_valid } 5. end
  58. ࣮૷ - Ξϓϩʔν 1. RSpec.conf i gure do |conf i

    g| 2. conf i g.around(:example) do |example| 3. example.run 4. end 5. end example.example.metadata[:block] = > #<Proc:0 x 00007f9db0a06040 /Users/neko314/ sample_app/spec/models/user_spec.rb:4> # sample_app/spec/models/user_spec.rb 1. require 'rails_helper' 2. 3. RSpec.describe User, type: :model do 4. it { expect(FactoryBot.create(:user)).to be_valid } 5. end
  59. औಘͨ͠procʹͲ͏खΛೖΕΔ͔ʁ🤔 ࣮૷

  60. ΍Γ͍ͨ͜ͱΛ֬ೝ ࣮૷ # sample_app/spec/models/user_spec.rb 1. require 'rails_helper' 2. 3. RSpec.describe

    User, type: :model do 4. it { expect(FactoryBot.create(:user)).to be_valid } 5. end
  61. ΍Γ͍ͨ͜ͱΛ֬ೝ ࣮૷ # sample_app/spec/models/user_spec.rb 1. require 'rails_helper' 2. 3. RSpec.describe

    User, type: :model do 4. it { expect(FactoryBot.create(:user)).to be_valid } 5. end build ΍ build_stubbed ʹ͍ͨ͠
  62. ΍Γ͍ͨ͜ͱΛ֬ೝ ࣮૷ # sample_app/spec/models/user_spec.rb 1. require 'rails_helper' 2. 3. RSpec.describe

    User, type: :model do 4. it { expect(FactoryBot.create(:user)).to be_valid } 5. end ·ͣ build ʹ͢Δ͜ͱΛߟ͑Δ
  63. ࣮૷ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ จࣈྻ͔Βੜ੒ͨ͠ Proc ΦϒδΣΫτ Ճ޻ͨ͠จࣈྻ ϝλσʔλͷ Proc ΦϒδΣΫτ ࣮ߦ݁Ռ

  64. ࣮૷ ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ

  65. ࣮૷ example.example.metadata[:block].to_s ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ to_s ΍ inspect ͯ͠ΈΔ

  66. ࣮૷ example.example.metadata[:block].to_s # = > "#<Proc:0 x 00007fc6b29ae090 /Users/neko314/ sample_app/spec/models/user_spec.rb:4>"

    ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ to_s ΍ inspect ͯ͠ΈΔ
  67. ࣮૷ example.example.metadata[:block].to_s # = > "#<Proc:0 x 00007fc6b29ae090 /Users/neko314/ sample_app/spec/models/user_spec.rb:4>"

    ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ to_s ΍ inspect ͯ͠ΈΔ 😇
  68. ࣮૷ RubyVM : : AbstractSyntaxTree.of(example.example.metadata[:bl ock]) ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ

    ASTΛऔಘͯ͠ΈΔ
  69. ࣮૷ RubyVM : : AbstractSyntaxTree.of(example.example.metadata[:bl ock]) # = > #<RubyVM

    : : AbstractSyntaxTree : : Node:SCOPE@4 : 5-4 : 53> ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ ASTΛऔಘͯ͠ΈΔ
  70. ࣮૷ RubyVM : : AbstractSyntaxTree.of(example.example.metadata[:bl ock]) # = > #<RubyVM

    : : AbstractSyntaxTree : : Node:SCOPE@4 : 5-4 : 53> ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ ASTΛऔಘͯ͠ΈΔ 😇Ճ޻ʹࣦഊͯ͠அ೦
  71. ࣮૷ module ProcParser ref i ne Proc do def body

    # RubyVM : : InstructionSequence ͰऔಘͰ͖Δ γʔέϯεΛ΋ͱʹ spec ϑΝΠϧ͔ΒจࣈྻΛऔಘ end end end ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ
  72. ࣮૷ example.example.metadata[:block].body ϝλσʔλͷ Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ

  73. ࣮૷ example.example.metadata[:block].body # = > " expect(FactoryBot.create(:user)).to be_valid " ϝλσʔλͷ

    Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ
  74. ࣮૷ example.example.metadata[:block].body # = > " expect(FactoryBot.create(:user)).to be_valid " ϝλσʔλͷ

    Proc ΦϒδΣΫτ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ 🎉🎉🎉🎉🎉🎉
  75. ࣮૷ 🙏 ͘͢͝ࢀߟʹ͠·ͨ͠ʂ 🙏 Ruby ͷϒϩοΫߏจͷத਎Λจࣈྻͱͯ͠औಘ͢Δ by @osyo-manga https://secret-garden.hatenablog.com/entry/ 2019/09/08/145037

  76. ࣮૷ ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ Ճ޻ͨ͠จࣈྻ " expect(FactoryBot.create(:user)).to be_valid\n"

  77. ࣮૷ " expect(FactoryBot.create(:user)).to be_valid\n" .gsub("create", "build") ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ Ճ޻ͨ͠จࣈྻ " expect(FactoryBot.create(:user)).to

    be_valid\n"
  78. ࣮૷ " expect(FactoryBot.create(:user)).to be_valid\n" .gsub("create", "build") ఆٛ͞Ε͍ͯΔखଓ͖ͷจࣈྻ Ճ޻ͨ͠จࣈྻ " expect(FactoryBot.create(:user)).to

    be_valid\n" " expect(FactoryBot.build(:user)).to be_valid\n"
  79. ࣮૷ Ճ޻ͨ͠จࣈྻ จࣈྻ͔Βੜ੒ͨ͠ Proc ΦϒδΣΫτ " expect(FactoryBot.build(:user)).to be_valid\n"

  80. ࣮૷ new_body = "Proc.new { " expect(FactoryBot.build(:user)).to be_valid\n" }" eval(new_body)

    Ճ޻ͨ͠จࣈྻ จࣈྻ͔Βੜ੒ͨ͠ Proc ΦϒδΣΫτ " expect(FactoryBot.build(:user)).to be_valid\n"
  81. ࣮૷ new_body = "Proc.new { " expect(FactoryBot.build(:user)).to be_valid\n" }" eval(new_body)

    Ճ޻ͨ͠จࣈྻ จࣈྻ͔Βੜ੒ͨ͠ Proc ΦϒδΣΫτ " expect(FactoryBot.build(:user)).to be_valid\n" #<Proc:0 x 00007fa08a88cf70 (eval) : 1>
  82. ࣮૷ new_example = eval(new_body) # = > #<Proc:0 x 00007fa08a88cf70

    (eval) : 1> จࣈྻ͔Βੜ੒ͨ͠ Proc ΦϒδΣΫτ ࣮ߦ݁Ռ
  83. ࣮૷ def run_successfully?(example) example.call true rescue StandardError false end จࣈྻ͔Βੜ੒ͨ͠

    Proc ΦϒδΣΫτ ࣮ߦ݁Ռ
  84. ࣮૷ new_example = eval(new_body) # = > #<Proc:0 x 00007fa08a88cf70

    (eval) : 1> จࣈྻ͔Βੜ੒ͨ͠ Proc ΦϒδΣΫτ ࣮ߦ݁Ռ run_successfully?(new_example) True / False
  85. ࣮૷ Ҏ্ ͕ create Λ build ʹͯ͠ςετΛ࣮ߦ͢Δํ๏Ͱͨ͠ build_stubbed ΋ಉ༷Ͱ͢

  86. 1. create ͍ͯ͠ΔςετΛͦͷ··࣮ߦ͢Δ 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠

    ͯςετΛ࣮ߦ͢Δ 3. ࠷దͳ build strategy ΛબͿ ࣮૷ - ΍Γ͍ͨॲཧ
  87. 1. create ͍ͯ͠ΔςετΛͦͷ··࣮ߦ͢Δ 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠

    ͯςετΛ࣮ߦ͢Δ 3. ࠷దͳ build strategy ΛબͿ ࣮૷ - ΍Γ͍ͨॲཧ
  88. 1. create ͍ͯ͠ΔςετΛͦͷ··࣮ߦ͢Δ 2. create ͷՕॴΛ build ΍ build_stubbed ʹ͠

    ͯςετΛ࣮ߦ͢Δ 3. ࠷దͳ build strategy ΛબͿ 3.1. ϝοηʔδΛग़ྗ ࣮૷ - ΍Γ͍ͨॲཧ
  89. ࣮૷ ࣮ߦ݁Ռ build strategy ςετ͕௨Βͳ͍ - build Ͱύε build build_stubbed

    Ͱύε build_stubbed create Ͱύε create build strategyͷબͼํ
  90. 🎉੒Ռ🎉

  91. ੒Ռ $ FATORYSTRATEGIST=1 bin/rspec spec/models/user_spec.rb "./spec/models/user_spec.rb:4 create can be replaced

    to build" . Finished in 0.03062 seconds ( fi les took 5.47 seconds to load)1 example, 0 failures
  92. ੒Ռ $ FATORYSTRATEGIST=1 bin/rspec spec/models/user_spec.rb "./spec/models/user_spec.rb:4 create can be replaced

    to build" . Finished in 0.03062 seconds ( fi les took 5.47 seconds to load)1 example, 0 failures
  93. ੒Ռ $ FATORYSTRATEGIST=1 bin/rspec spec/models/user_spec.rb "./spec/models/user_spec.rb:4 create can be replaced

    to build" . Finished in 0.03062 seconds ( fi les took 5.47 seconds to load)1 example, 0 failures 🎉🎉🎉🎉🎉🎉
  94. ͜Ε͔Βͷ࿩

  95. • ࡶͳ gsub Λ΍Ίͯʮ1ͭ1ͭͷ create ΛνΣο Ϋ͢ΔʯΛ࣮ݱ͍ͨ͠ • ΑΓෳࡶͳςετίʔυʹରԠ͍ͨ͠ •

    ग़ྗϝοηʔδΛΘ͔Γ΍͍ͨ͘͢͠ • ଞͷςετϑϨʔϜϫʔΫͰ΋࢖͑ΔΑ͏ʹͨ͠ ͍ ͜Ε͔Β΍Γ͍ͨ͜ͱ
  96. • ͜Μͳʹ೉͍͠ͱ͸… • ASTɺISeq ΛॳΊͯࣗ෼Ͱ৮ͬͨʂ • Ruby 3.1 ͷ AST

    ָ͕͠Έ • ࢼߦࡨޡ͸͍͍ͧ ײ૝
  97. ͋Γ͕ͱ͏͍͟͝·ͨ͠🙂