Rspec for Beginners - Jason Arhart

2.3k

Rspec for Beginners - Jason Arhart

B044a0f039af800f4df09bf3b2465f18?s=128

Las Vegas Ruby Group

July 31, 2013
Tweet

Transcript

  1. RSpec for Beginners by Jason Arhart Thursday, August 1, 13

  2. What is RSpec? Thursday, August 1, 13

  3. What is RSpec? RSpec is a TDD tool for Ruby

    Thursday, August 1, 13
  4. What is TDD? Thursday, August 1, 13

  5. What is TDD? • Test-Driven Development Thursday, August 1, 13

  6. What is TDD? • Test-Driven Development • TDD is a

    development technique Thursday, August 1, 13
  7. What is TDD? • Test-Driven Development • TDD is a

    development technique • The tests are written first Thursday, August 1, 13
  8. Why do TDD? Thursday, August 1, 13

  9. Why do TDD? • Code is testable from the start

    Thursday, August 1, 13
  10. Why do TDD? • Code is testable from the start

    • Ensures that your tests actually work Thursday, August 1, 13
  11. Why do TDD? • Code is testable from the start

    • Ensures that your tests actually work • Focus on what before how Thursday, August 1, 13
  12. Why do TDD? • Code is testable from the start

    • Ensures that your tests actually work • Focus on what before how • Consistent test coverage Thursday, August 1, 13
  13. Why do TDD? • Code is testable from the start

    • Ensures that your tests actually work • Focus on what before how • Consistent test coverage • Enables refactoring Thursday, August 1, 13
  14. Why do TDD? • Code is testable from the start

    • Ensures that your tests actually work • Focus on what before how • Consistent test coverage • Enables refactoring • Less time spent debugging Thursday, August 1, 13
  15. The TDD Cycle Thursday, August 1, 13

  16. The TDD Cycle Step 1: Write a test... Thursday, August

    1, 13
  17. ..watch it fail Thursday, August 1, 13

  18. The TDD Cycle Step 2: Make the test pass Thursday,

    August 1, 13
  19. Celebrate! Thursday, August 1, 13

  20. The TDD Cycle Step 3: Refactor Thursday, August 1, 13

  21. Make it beautiful Thursday, August 1, 13

  22. Make it beautiful Refactor your tests too! Thursday, August 1,

    13
  23. Repeat! Thursday, August 1, 13

  24. Anatomy of a TDD Tool Thursday, August 1, 13

  25. Anatomy of a TDD Tool • A library for writing

    automated tests Thursday, August 1, 13
  26. Anatomy of a TDD Tool • A library for writing

    automated tests • A framework for organizing tests into a test suite Thursday, August 1, 13
  27. Anatomy of a TDD Tool • A library for writing

    automated tests • A framework for organizing tests into a test suite • A way to run the tests Thursday, August 1, 13
  28. Why RSpec? Thursday, August 1, 13

  29. Why RSpec? • RSpec focuses on expected behavior Thursday, August

    1, 13
  30. Why RSpec? • RSpec focuses on expected behavior • RSpec

    specifications are executable documentation Thursday, August 1, 13
  31. Why RSpec? • RSpec focuses on expected behavior • RSpec

    specifications are executable documentation • RSpec provides a rich set of tools for organizing test cases Thursday, August 1, 13
  32. Why RSpec? • RSpec focuses on expected behavior • RSpec

    specifications are executable documentation • RSpec provides a rich set of tools for organizing test cases • RSpec is currently very popular Thursday, August 1, 13
  33. Getting Started Thursday, August 1, 13

  34. Getting Started Thursday, August 1, 13

  35. Getting Started Thursday, August 1, 13

  36. Getting Started Thursday, August 1, 13

  37. Getting Started Thursday, August 1, 13

  38. spec/spec_helper.rb Thursday, August 1, 13

  39. spec/spec_helper.rb Thursday, August 1, 13

  40. Specifications Thursday, August 1, 13

  41. Specifications • RSpec focuses on tests as executable specifications Thursday,

    August 1, 13
  42. Specifications • RSpec focuses on tests as executable specifications •

    Specifications describe expected behavior Thursday, August 1, 13
  43. Specifications • RSpec focuses on tests as executable specifications •

    Specifications describe expected behavior • Executable examples of expected behavior Thursday, August 1, 13
  44. Specifications • RSpec focuses on tests as executable specifications •

    Specifications describe expected behavior • Executable examples of expected behavior • Examples are executed in a controlled context Thursday, August 1, 13
  45. Stack Thursday, August 1, 13

  46. Stack Thursday, August 1, 13

  47. Specification Thursday, August 1, 13

  48. Specification Thursday, August 1, 13

  49. Specification Thursday, August 1, 13

  50. Specification Thursday, August 1, 13

  51. Specification Thursday, August 1, 13

  52. Specification Thursday, August 1, 13

  53. Specification Thursday, August 1, 13

  54. Specification Thursday, August 1, 13

  55. Expectations Thursday, August 1, 13

  56. Expectations Thursday, August 1, 13

  57. Expectations Thursday, August 1, 13

  58. Expectations Thursday, August 1, 13

  59. Expectations Thursday, August 1, 13

  60. Expectations Thursday, August 1, 13

  61. Expectations Thursday, August 1, 13

  62. Expectations Thursday, August 1, 13

  63. Expectations Thursday, August 1, 13

  64. Expectations Thursday, August 1, 13

  65. Matchers Thursday, August 1, 13

  66. Matchers Thursday, August 1, 13

  67. Matchers Thursday, August 1, 13

  68. Matchers Thursday, August 1, 13

  69. Matchers Thursday, August 1, 13

  70. Nested #describe Thursday, August 1, 13

  71. Nested #describe Thursday, August 1, 13

  72. Nested #describe Thursday, August 1, 13

  73. Nested #describe Thursday, August 1, 13

  74. Nested #describe Thursday, August 1, 13

  75. Refactoring Thursday, August 1, 13

  76. Refactoring Thursday, August 1, 13

  77. subject Thursday, August 1, 13

  78. subject Thursday, August 1, 13

  79. subject Thursday, August 1, 13

  80. subject Thursday, August 1, 13

  81. subject Thursday, August 1, 13

  82. let Thursday, August 1, 13

  83. let Thursday, August 1, 13

  84. let Thursday, August 1, 13

  85. let Thursday, August 1, 13

  86. let Thursday, August 1, 13

  87. let Thursday, August 1, 13

  88. Nested Context Thursday, August 1, 13

  89. Nested Context Thursday, August 1, 13

  90. Nested Context Thursday, August 1, 13

  91. Nested Context Thursday, August 1, 13

  92. before Thursday, August 1, 13

  93. before Thursday, August 1, 13

  94. Other Features Thursday, August 1, 13

  95. Other Features • More hooks Thursday, August 1, 13

  96. Other Features • More hooks • Built-in matchers for almost

    any occasion Thursday, August 1, 13
  97. Other Features • More hooks • Built-in matchers for almost

    any occasion • Custom matchers for special occasions Thursday, August 1, 13
  98. Other Features • More hooks • Built-in matchers for almost

    any occasion • Custom matchers for special occasions • Shared examples Thursday, August 1, 13
  99. Other Features • More hooks • Built-in matchers for almost

    any occasion • Custom matchers for special occasions • Shared examples • Shared context Thursday, August 1, 13
  100. Other Features • More hooks • Built-in matchers for almost

    any occasion • Custom matchers for special occasions • Shared examples • Shared context • Filtering Thursday, August 1, 13
  101. Other Features • More hooks • Built-in matchers for almost

    any occasion • Custom matchers for special occasions • Shared examples • Shared context • Filtering • Metadata Thursday, August 1, 13
  102. Thursday, August 1, 13