Summary
- Git (Branch, rebase, interactive mode…)
- Grunt (install grunt-cli locally)
- Browserify
- dist directory
- Makefile (Usual start)
- Test Fixture
Session
I am going to try to keep this summaries shorter and I am going to try a new format.
####1. Git
We talked about the options of Git with branches so I could save a middle done
work and nobody needs to see it.
For that I hace to find out about the following commands:
$ git rebase
$ git branch
$ git rebase interactive mode
Git is really large, but branches are essential.
####2. Grunt
I had to install grunt-cli at my package.json npm install grunt-cli --save-dev
first I’ve checked the version with which grunt
####3. Browserify
It is important to define relatives $PATH at our files so at the package.json we
updated it and gave indications for the relative path of the command Browserify with:
./node_modules/.bin/browserify
Check were the commands are located if we want them to properly work.
####4. Dist/
The browserify file should go into a dist directory.
All build artifacts go into the dist/ folder.
They should be automatically generated by a command like make dist
Usually this folder is served from the server to the browser in gzip format.
tarball == tar.gz
tar -zcvf folder/ name.tar.gz
gzip
compression algorithm
AirCrewMentor likes to run all the test on the dist/ folder.
the dist/ folder is where the final project goes.
####5. Makefile
At the make file, AirCrewMentor always include this 3 lines, we need to be sure about the path and that they are using bash, they could be using other ones (sh, zsh)
SHELL = /bin/bash
MAKEFLAGS += --no-print-directory --silent
export PATH := ./node_modules/.bin:$(PATH):./bin
####6. Test Fixtures
When we have multiple test we put the files into the folder called test.
To run it we use the make test
or mocha test
To run multiple sequences of a test, we can use test fixtures that is a JSON file with all the possible data we are going to need to run it.
{“input”: [params here], “output”: “123 $”}
For the fixtures we are going to include a folder called “fixtures” inside test.
At the test file we need to pass a function to generate a closure, because when the mocha test starts, looses the environment and it would only pass one test, it wouldn’t itinerate trough all the fixtures we have ready. @AirCrewMentor
An example:
for (var i = 0; i < fixtures.length; i++) {
it("should generate " + fixtures[i].output, checkFixtures(fixtures[i]));
}
});
function checkFixtures(fixture) {
return function() {
expect(formatMoney.apply(null, fixture.input)).to.be(fixture.output);
};
}
Here we used the apply method
Evolution.
AirCrewMentor seemed happy with my evolution, I am at the last chapter of the book.
Homework
- Group Testing files.
- Add Fixtures
- Refactor the format_money to accept objects on function.
options = {number: 123456, places: 3, symbol: “$”, thousand: “,”, “decimail: “.”};
formanMoney(options)
Thanks AirCrewMentor for your time. You are amazing.