Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 2.47 KB

README.md

File metadata and controls

60 lines (43 loc) · 2.47 KB

Cooking recipes by testing first

This repo is a step by step example to learn how to create Chef cookbooks by testing first.

I'll try to follow the BDD/TDD approach and try the different tools from the Chef's ecosystem such Test-Kitchen, ChefSpec, ServerSpec, Foodcritic...

I won't try to describe the right way, just what makes more sense to me based in my own experience. It'll serve me to learn the tools, to proof some ideas and to have some examples. Also to have documented problem I'll run into and the solutions I'll find. I hope this help someone else.

NOTE: This repo and this document are WIP, it's not finished and you'll miss some final steps (by now).

The process

The process will be:

  1. Setup the minimal environment for testing how the new system should behave
  2. Create the minimal tests to check if the system behave as I wish
  3. Check that the tests doesn't pass
  4. Think about the simplest technical way to pass those tests
  5. Setup the minimal environment for testing this technical approach
  6. Create the minimal tests to check that minimal technical approach
  7. Check that the tests doesn't pass
  8. Create the minimal recipe to pass the technical tests
  9. Check that the tests do pass the technical tests
  10. Check that the tests do pass the behavior tests

Once I have this, I will think in another system behavior and repeat the process.

The use case

As example I will use the following example:

"I'd like to access with my browser to the system and read the sentence 'Hello world!' in my browser"

Pretty simple and common, isn't it?

How to organize the code an examples

I'll call the project webtest and I'll create a directory for every step I'll take. Something like this:

|-webtest-0
|-webtest-1
|-webtest-2
|-...
`-webtest-X

Each directory should be self-explanatory with its own README file to explain what is the goal for that step, the dependencies, processes and difficulties found in that step. See the current ones:

  • Webtest-0: Setup the testing environment.
  • Webtest-1: Define the business goal and write the integration tests.
  • Webtest-2: Define the technical specs and write some unit tests.
  • Webtest-3: Start writing recipes to pass the tests.