-
Notifications
You must be signed in to change notification settings - Fork 8
Authoring a Kata
I started a github project where everyone can contribute the katas they author using the kata gem. You learned when setting up the practice session your first step was to clone this repo:
git clone git@github.com:wbailey/code_katas
Now simply go into this repo, create a new branch, and then author your kata using the DSL described in the next section. I am always happy when folks give me a PR including new material!
Authoring a kata is as simple as installing this gem and creating a ruby file much like an RSpec test as illustrated below:
There are 7 methods that can be used to author a kata that have a hierarchy illustrated below:
1. kata
2. context
3. requirement
4. detail
5. example
6. questions
7. question
-
The kata() method sets up the test to administer and starts the clock running. It takes 2 arguments:
- string - The name of the kata that will be displayed when taking it as well as being used in creating the parent directory of the github repo during setup.
- &block - A ruby block that includes calls to context() or requirement()
-
The context() method allows for grouping of requirements with 2 arguments:
- string - A description of the provided context
- &block - A ruby block consisting of a call to requirement()
this method call is optional and not required to define a kata.
-
The requirement() method is the heart of a kata as it is used to provide the business rules that the code should provide solutions to. It follows the same pattern of the other methods with 2 arguments:
- string - A description of the requirement that the code implementing the kata should meet
- &block - A ruby block consisting of calls to detail() or example()
-
The detail() method takes a single argument allowing for further definition of a requirement. This method can be called repeatedly in a block.
- string - A description of the detail of requirement
-
The example() method takes a single argument allowing for illustration of examples of the requirement in practice
- string - An example that will help illustrate the requirement in practice
-
The questions() method allows you define questions after completing the kata to challenge the taker on how and why they took certain directions or made the decisions they made
- &block - A ruby block consisting of calls to question()
-
The question() method allows well the obvious
- string - Text of the question to ask the taker