TDD with Ruby
Ismael G Marín C
@igmarin
Comunidades
• Elixir Bajío (Facebook)
• Bajio on Rails (Facebook)
What is the primary goal of TDD?
• One view is the goal of TDD is
specification and not validation
In other words, it’s one way to think
through your requirements or design
before your write your functional code
(implying that TDD is both an important
agile requirements and agile design
–Ron Jeffries
“the goal of TDD is to
write clean code that
works.”
TDD Cycle
• Add a test
• Run all the test and see if the new test fails
• Write the code
• Run test
• Refactor code
• Repeat
Write a
failing test
Make the
test pass
Refactor
red - green - refactor
Two levels of TDD
• Acceptance TDD (ATDD). With ATDD you write a single
acceptance test, or behavioral specification depending on
your preferred terminology, and then just enough production
functionality/code to fulfill that test.
• Developer TDD. With developer TDD you write a single
developer test, sometimes inaccurately referred to as a unit
test, and then just enough production code to fulfill that test.
TDD with Ruby
TDD with Ruby

TDD with Ruby

  • 1.
    TDD with Ruby IsmaelG Marín C @igmarin
  • 2.
    Comunidades • Elixir Bajío(Facebook) • Bajio on Rails (Facebook)
  • 3.
    What is theprimary goal of TDD? • One view is the goal of TDD is specification and not validation In other words, it’s one way to think through your requirements or design before your write your functional code (implying that TDD is both an important agile requirements and agile design
  • 4.
    –Ron Jeffries “the goalof TDD is to write clean code that works.”
  • 5.
    TDD Cycle • Adda test • Run all the test and see if the new test fails • Write the code • Run test • Refactor code • Repeat
  • 6.
    Write a failing test Makethe test pass Refactor red - green - refactor
  • 8.
    Two levels ofTDD • Acceptance TDD (ATDD). With ATDD you write a single acceptance test, or behavioral specification depending on your preferred terminology, and then just enough production functionality/code to fulfill that test. • Developer TDD. With developer TDD you write a single developer test, sometimes inaccurately referred to as a unit test, and then just enough production code to fulfill that test.