SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Can you TDD Rails?
@andrzejkrzywda
(in love/hate relationship with Rails, since 2004)
Arkency
• “What does this code really do?”
• “Can I safely remove it?”
• “I see dead code”
• “I’m afraid to change this code”
• “This code is ugly”
• “Oh, it’s a mock that returns a mock that returns
a mock”
Things developers say
Fear/hate of existing code
• “Where do I start with this feature?”
• “Will I break anything?”
• “I’ll just add a bool parameter here and an if
there”
• “Changing this will break dozens of tests”
Fear of new code
hypothesis:
!
TDD can help us with those
problems
• “What does this code really do?”
• “Can I safely remove it?”
• “I see dead code”
• “I’m afraid to change this code”
• “This code is ugly”
• “Oh, it’s a mock that returns a mock that returns
a mock”
Things developers say
• “Where do I start with this feature?”
• “Will I break anything?”
• “I’ll just add a bool parameter here and an if
there”
• “Changing this will break dozens of tests”
Fear-driven coding
is not
fun
Fear-driven improvement
is
fun
Skills
Hard skills
vs
soft skills
Hard skills
!
where computers excel
Soft skills
!
where humans excel
Chess - hard skills
• endings
• openings (theory)
• realizing advantage
• tactics (combinations)
Chess - soft skills
• recognize patterns
• understand nuances
• strategy
• plans
In a chess game (40-50 moves)
we’ve got about 4-5 critical
positions that require more
thinking
Rails
Rails - Hard skills
• Rails Controllers API
• Rails views API
• ActiveRecord API
• CoffeeScript/JavaScript
• Ruby stdlib
• refactoring techniques
Rails - soft skills
• understand requirements
• implement business rules
• applying refactoring
• splitting modules / services
• isolating from Rails
• isolating from Gems
TDD
TDD == TestFirst + Refactoring
Red
Green
Refactor
“but TDD is hard with Rails”
The TDD drama
!
“If TDD with Rails is hard, then
something is wrong with TDD.”
TDD is ne
Rails is ne
!
Most likely, your code is not ne
TDD skills
TDD hard skills
• tools - rspec, xunit, guard
• automatic run
• full suite vs partial suite
• TDD JavaScript tools
• IDEs
TDD soft skills
• spikes
• GTD
• Continuous delivery (commit after every cycle)
• triangulation
• isolate from the framework (aka the Rails sandwich)
• tests refactoring
• when to mock?
Spikes
• “It’s not clear to me, what I need to do”
• a prototype
• throw-away code
• cowboy hacking
• timeboxed
• make notes
• can be temporarily deployed, if it’s “secure” just to feel it
Getting Things Done
• “I know what to do, now just do it”
• checklists
• Pomodoro
• procrastination
Continuous Delivery
• Commit/push after every red/green/refactor
cycle
• push == deploy
• small steps
• don’t break the existing code
• always green
TDD triangulation
• the simplest possible test
• make it green in the stupid way
• next test
• implement with an ‘if’
• next test
• refactor and implement the right way
Framework isolation
• controller? - extract service object or a query
object, as early as possible
• model? - move logic to service object
• no need to test ActiveRecord
• extract repository object
• render views with locals
tests refactoring
• test is code too
• make it short, elegant, easy to read
• apply Clean Code rules
• feel free to remove some tests
when to mock?
• boundaries
• db access
How can I improve at TDD?
exercising TDD
• code kata
• YouTube: TDD
• extract business logic as a gem, TDD that
• “domain spike” - what if all objects can live in
memory (no db) and there’s no boundaries (http,
api), just objects
• 15 minutes a day
It’s all up to you to
learn how to TDD Rails
Thanks!
http://rails-refactoring.com/

Weitere ähnliche Inhalte

Was ist angesagt?

'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by  Dmytro Gusev'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by  Dmytro Gusev
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
OdessaJS Conf
 
WTF TDD?
WTF TDD?WTF TDD?
WTF TDD?
jeremyw
 
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
OdessaJS Conf
 

Was ist angesagt? (20)

Testing sync engine
Testing sync engineTesting sync engine
Testing sync engine
 
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by  Dmytro Gusev'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by  Dmytro Gusev
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
 
Tdd using Jasmine and karma
Tdd using  Jasmine and karmaTdd using  Jasmine and karma
Tdd using Jasmine and karma
 
Robot Framework :: Demo login application
Robot Framework :: Demo login applicationRobot Framework :: Demo login application
Robot Framework :: Demo login application
 
Automate test-oim
Automate test-oimAutomate test-oim
Automate test-oim
 
Scripting robot
Scripting robotScripting robot
Scripting robot
 
Robot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MRobot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh M
 
Cypress first impressions
Cypress first impressionsCypress first impressions
Cypress first impressions
 
Ruin your life using robot framework
Ruin your life using robot frameworkRuin your life using robot framework
Ruin your life using robot framework
 
How does Java 8 exert hidden power on Test Automation?
How does Java 8 exert hidden power on Test Automation?How does Java 8 exert hidden power on Test Automation?
How does Java 8 exert hidden power on Test Automation?
 
Barcamp Bangkhen :: Robot Framework
Barcamp Bangkhen :: Robot FrameworkBarcamp Bangkhen :: Robot Framework
Barcamp Bangkhen :: Robot Framework
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot Framework
 
Hello world - intro to node js
Hello world - intro to node jsHello world - intro to node js
Hello world - intro to node js
 
Acceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkAcceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot Framework
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?
 
WTF TDD?
WTF TDD?WTF TDD?
WTF TDD?
 
Selenium Camp 2016 - Effective UI tests scaling on Java
Selenium Camp 2016 - Effective UI tests scaling on JavaSelenium Camp 2016 - Effective UI tests scaling on Java
Selenium Camp 2016 - Effective UI tests scaling on Java
 
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
 
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarCypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
 

Ähnlich wie Can you TDD Rails?

Unbreaking Your Django Application
Unbreaking Your Django ApplicationUnbreaking Your Django Application
Unbreaking Your Django Application
OSCON Byrum
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
Testing gone-right
Testing gone-rightTesting gone-right
Testing gone-right
Jesse Wolgamott
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
rsebbe
 
Build software like a bag of marbles, not a castle of LEGOÂŽ
Build software like a bag of marbles, not a castle of LEGOÂŽBuild software like a bag of marbles, not a castle of LEGOÂŽ
Build software like a bag of marbles, not a castle of LEGOÂŽ
Hannes Lowette
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
IsaacSchlueter
 
Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012
Mike Clement
 

Ähnlich wie Can you TDD Rails? (20)

Unbreaking Your Django Application
Unbreaking Your Django ApplicationUnbreaking Your Django Application
Unbreaking Your Django Application
 
TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with Laravel
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
 
Testing gone-right
Testing gone-rightTesting gone-right
Testing gone-right
 
ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
 
Don't get blamed for your choices - Techorama 2019
Don't get blamed for your choices - Techorama 2019Don't get blamed for your choices - Techorama 2019
Don't get blamed for your choices - Techorama 2019
 
Build software like a bag of marbles, not a castle of LEGOÂŽ
Build software like a bag of marbles, not a castle of LEGOÂŽBuild software like a bag of marbles, not a castle of LEGOÂŽ
Build software like a bag of marbles, not a castle of LEGOÂŽ
 
Stop punching yourself in the face!
Stop punching yourself in the face!Stop punching yourself in the face!
Stop punching yourself in the face!
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your life
 
Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
 
Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012
 
The Cowardly Test-o-Phobe's Guide To Testing
The Cowardly Test-o-Phobe's Guide To TestingThe Cowardly Test-o-Phobe's Guide To Testing
The Cowardly Test-o-Phobe's Guide To Testing
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
 
Jest: Frontend Testing richtig gemacht @WebworkerNRW
Jest: Frontend Testing richtig gemacht @WebworkerNRWJest: Frontend Testing richtig gemacht @WebworkerNRW
Jest: Frontend Testing richtig gemacht @WebworkerNRW
 
Test Driven Development - a gentle introduction
Test Driven Development - a gentle introductionTest Driven Development - a gentle introduction
Test Driven Development - a gentle introduction
 

Mehr von Andrzej Krzywda

[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna
Andrzej Krzywda
 
Madeleine on Rails
Madeleine on RailsMadeleine on Rails
Madeleine on Rails
Andrzej Krzywda
 

Mehr von Andrzej Krzywda (20)

[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
 
[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?
 
Audit log with event sourcing
Audit log with event sourcingAudit log with event sourcing
Audit log with event sourcing
 
Event driven without microservices
Event driven without microservicesEvent driven without microservices
Event driven without microservices
 
From legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting stepsFrom legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting steps
 
Slack protips from Arkency
Slack protips from ArkencySlack protips from Arkency
Slack protips from Arkency
 
From Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, LvivFrom Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, Lviv
 
From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)
 
From legacy to DDD
From legacy to DDDFrom legacy to DDD
From legacy to DDD
 
DCI - the architecture from the future
DCI - the architecture from the futureDCI - the architecture from the future
DCI - the architecture from the future
 
Refactoring Rails applications with RubyMine
Refactoring Rails applications with RubyMineRefactoring Rails applications with RubyMine
Refactoring Rails applications with RubyMine
 
Beyond The Rails Way
Beyond The Rails WayBeyond The Rails Way
Beyond The Rails Way
 
Service objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacementService objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacement
 
Developer oriented
Developer orientedDeveloper oriented
Developer oriented
 
A programmer or a business consultant?
A programmer or a business consultant?A programmer or a business consultant?
A programmer or a business consultant?
 
Rails refactoring call for help
Rails refactoring call for helpRails refactoring call for help
Rails refactoring call for help
 
[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna
 
Use cases in the code with AOP
Use cases in the code with AOPUse cases in the code with AOP
Use cases in the code with AOP
 
Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]
 
Madeleine on Rails
Madeleine on RailsMadeleine on Rails
Madeleine on Rails
 

KĂźrzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

KĂźrzlich hochgeladen (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Can you TDD Rails?

  • 1. Can you TDD Rails? @andrzejkrzywda (in love/hate relationship with Rails, since 2004) Arkency
  • 2. • “What does this code really do?” • “Can I safely remove it?” • “I see dead code” • “I’m afraid to change this code” • “This code is ugly” • “Oh, it’s a mock that returns a mock that returns a mock” Things developers say
  • 4. • “Where do I start with this feature?” • “Will I break anything?” • “I’ll just add a bool parameter here and an if there” • “Changing this will break dozens of tests”
  • 5. Fear of new code
  • 6. hypothesis: ! TDD can help us with those problems
  • 7. • “What does this code really do?” • “Can I safely remove it?” • “I see dead code” • “I’m afraid to change this code” • “This code is ugly” • “Oh, it’s a mock that returns a mock that returns a mock” Things developers say
  • 8. • “Where do I start with this feature?” • “Will I break anything?” • “I’ll just add a bool parameter here and an if there” • “Changing this will break dozens of tests”
  • 15. Chess - hard skills • endings • openings (theory) • realizing advantage • tactics (combinations)
  • 16. Chess - soft skills • recognize patterns • understand nuances • strategy • plans
  • 17. In a chess game (40-50 moves) we’ve got about 4-5 critical positions that require more thinking
  • 18. Rails
  • 19. Rails - Hard skills • Rails Controllers API • Rails views API • ActiveRecord API • CoffeeScript/JavaScript • Ruby stdlib • refactoring techniques
  • 20. Rails - soft skills • understand requirements • implement business rules • applying refactoring • splitting modules / services • isolating from Rails • isolating from Gems
  • 21. TDD
  • 22. TDD == TestFirst + Refactoring
  • 24. “but TDD is hard with Rails”
  • 25. The TDD drama ! “If TDD with Rails is hard, then something is wrong with TDD.”
  • 26. TDD is ne Rails is ne ! Most likely, your code is not ne
  • 28. TDD hard skills • tools - rspec, xunit, guard • automatic run • full suite vs partial suite • TDD JavaScript tools • IDEs
  • 29. TDD soft skills • spikes • GTD • Continuous delivery (commit after every cycle) • triangulation • isolate from the framework (aka the Rails sandwich) • tests refactoring • when to mock?
  • 30. Spikes • “It’s not clear to me, what I need to do” • a prototype • throw-away code • cowboy hacking • timeboxed • make notes • can be temporarily deployed, if it’s “secure” just to feel it
  • 31. Getting Things Done • “I know what to do, now just do it” • checklists • Pomodoro • procrastination
  • 32. Continuous Delivery • Commit/push after every red/green/refactor cycle • push == deploy • small steps • don’t break the existing code • always green
  • 33. TDD triangulation • the simplest possible test • make it green in the stupid way • next test • implement with an ‘if’ • next test • refactor and implement the right way
  • 34. Framework isolation • controller? - extract service object or a query object, as early as possible • model? - move logic to service object • no need to test ActiveRecord • extract repository object • render views with locals
  • 35. tests refactoring • test is code too • make it short, elegant, easy to read • apply Clean Code rules • feel free to remove some tests
  • 36. when to mock? • boundaries • db access
  • 37. How can I improve at TDD?
  • 38. exercising TDD • code kata • YouTube: TDD • extract business logic as a gem, TDD that • “domain spike” - what if all objects can live in memory (no db) and there’s no boundaries (http, api), just objects • 15 minutes a day
  • 39. It’s all up to you to learn how to TDD Rails Thanks! http://rails-refactoring.com/