Koans: learn CoffeeScript by doing it
The goal of the CoffeeScript koans is to teach you CoffeeScript programming through actually doing it, in a test-first fashion.
When you first run the Koans, you'll be presented with a run-time error and a stack trace indicating where the error occurred. Your goal is to make the error go away. As you fix each error, you should learn something about the CoffeeScript language and functional programming in general.
Your journey towards CoffeeScript enlightenment starts in the Koans folder with the AboutExpects.coffee file.
These Koans will be very simple, so don't over-think them! As you progress through more Koans, more and more CoffeeScript syntax will be introduced which will allow you to solve more complicated problems and use more advanced techniques.
Install dependencies by using npm from the command line:
Start with copying the file koans/AboutShould.coffee to the completed-koans/ folder.
Run the tests with Mocha on the command line:
You should see the following output:
About Should 1) should expect true - should have filled in values - should understand type coercion is fixed - should expect equality - should assert equality a better way
0 passing (7ms)
You'll see that one of the tests is failing, and that the other 4 have been temporarily disabled (marked as 'pending').
Edit the AboutShould.coffee file (your copy in the completed-koans/ folder) with the editor or IDE of your choice and follow the directions to fix the problem in the first test.
When you think you've fixed the problem, run the tests again.npm test
When that test passes, enable the next pending test. Rinse and repeat until all tests turn green, simples :-)
When you're done with AboutShould.coffee, copy another file from the koans/ folder to the completed-koans/ folder and start work on that.
I would suggest trying them in the following order, but it is not prescriptive:
If you want to just test a single test file, you can do it like this: (remember to add in the name of your file)mocha --compilers coffee:coffee-script/register -R spec completed-koans/FILE-NAME-GOES-HERE.coffee
If you want mocha to watch your files for changes and rerun the tests automagically when you save changes to a test file, simply use:npm run watch
Have fun, and I hope you enjoy playing with CoffeeScript!
Endorse this project
To say 'thanks' please endorse this project on Coderwall by clicking the button below:
Or, if you happen to be in London, please drop by for a chat and buy me a beer!
Inspirations & thanks
The text below is a human-readable summary of (and not a substitute for) the license, contained in the LICENSE file.
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
You are free to:
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.