This repository contains supporting materials for the Test-Driven Tuesday workshop I'm currenly running.
The code katas and other exercises you'll find here should help you to understand the basics of JavaScript and Test-Driven Development (TDD) using node.js and popular automation tools.
You can use any IDE or text editor you like to play with the code here, but for the purpose of this workshop and its context I'll assume the following:
We will now create a fork of our repo so you can easily keep it in sync with this one. You will be able to easily pull from this repo, but push to your fork.
https://github.com/<MyGitHubAccount>/test-driven-tuesday
(learn more about forking from github manual)git clone https://github.com/jan-molak/test-driven-tuesday
git remote set-url --push origin https://github.com/<MyGitHubAccount>/test-driven-tuesday
Now you can git pull
from origin and git push
to your fork without verbose commands like git pull origin master
. Later when you want to contribute back please raise a Pull Request (PR) on your fork in github site to merge changes.
npm install
in the directory where you've cloned the project to. Remember to re-run npm install whenever the package.json
file is changed
$PATH
by adding the following entry to your .bashrc
or .zshrc
PATH=$PATH:./node_modules/.bin # Add node_modules binaries
grunt
in your project directory. You should get output similar to the following:$> grunt Running "clean:0" (clean) task
Running "mochacov:watch" (mochacov) task
# ... here goes the test output
0 passing (7ms)
38 pending
Done, without errors.
$> git stash
$> git pull upstream master
$> git stash apply
You can find the details under spec/exercises/objects_under_construction
Postcode exercise has been originally designed by Antony Marcano
"The 'Fizz-Buzz test' is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag." - Ward Cunningham
Steps:
Lets divide this into different steps so, we can easily write and test this:
FizzBuzz kata has been designed by Imran Ghory
add("taking,a,string,of,comma,separated,numbers")
""
or "1"
or "1,2"
add
method to handle an unknown number of numbersadd
method to handle new lines between numbers (instead of commas).
"\n2,3"
(will equal 6)"1,\n"
(not need to prove it - just clarifying)"//[delimiter]\n[numbers...]"
for example "/;\n1;2"
should return three where the default delimiter is ';'
.add
with a negative number will throw an exception "negatives not allowed" - and the negative that was passed.Functional programming katas are inspired by exercises from http://nodeschool.io/#functionaljs Those exercises have been modified to make the automated verification of results more prominent and easier to understand.
The Little Mocker exercise is based on The Little Mocker blog post by Uncle Bob Martin