comet is a gem used for practicing your Ruby skills. It downloads Ruby exercises that come with a test suite that you can run to check if your implementation is correct. To get started, follow the instructions in this guide.
This section will guide you through the initial setup for comet.
- Install the gem:
$ gem install comet
- Create a working directory for the exercises and change into it:
$ mkdir -p ~/Dropbox/comet
$ cd ~/Dropbox/comet
- Initialize the directory for use with comet:
$ comet init
-
At this point you will be prompted for your e-mail, login token, and a server address. You can create your account and login token by visiting http://comet.launchacademy.com and signing in with your Github account. Clicking on @username in the top-left corner of the page and then Your Account will reveal your login token. For the server, use
comet.launchacademy.com
. -
Run the following command to view the available exercises:
$ comet list
If everything is setup correctly you should see a list of exercises printed to the screen.
Here is a sample run of the initialization process:
$ gem install comet
...
Successfully installed comet-0.0.7
10 gems installed
$ mkdir -p ~/Dropbox/comet
$ cd ~/Dropbox/comet
$ comet init
Email: adam.sheehan@launchacademy.com
Token: 4d53da0b358940802c2e23d8464c5490
Server: comet.launchacademy.com
$ comet list
( 11) Flow Control: Odd Numbers (easy)
( 26) Recursion: Fibonacci Numbers (intermediate)
...
To see which exercises are available, use the comet list
command:
$ comet list
( 23) Iteration and Arrays: Max Number (easy)
( 26) Recursion: Fibonacci Numbers (intermediate)
...
This will show a list of exercises in various categories along with their difficulty.
The first column shown in comet list
is the exercise ID. Use this ID to download the exercise and unpack it in your comet directory. For example, to download the Max Number exercise shown above you can use the comet fetch
command and pass in the ID of 23 as an argument:
$ comet fetch 23
Downloaded kata to /home/asheehan/Dropbox/comet/max_number.
Now there should be a new folder in the comet directory containing the Max Number exercise. Within the folder there is a README.md
file containing the instructions for the exercise, a test
folder that contains the automated test suite, and a lib
folder where you'll complete the exercise:
max_number
├── lib
│ └── max_number.rb
├── README.md
└── test
└── max_number_test.rb
To run the automated test suite, use the comet test
command from within the exercise directory:
$ cd max_number
$ comet test
F
# Test failures here ....
Finished in 0.00071 seconds
1 example, 1 failure
Failed examples:
rspec ./test/max_number_test.rb:8 # max_number returns the largest integer
This will run the test suite found in test/max_number_test.rb
. Review that file to see if you can figure out why the test is failing.
Once you have an understanding of what is being tested, complete the exercise by modifying lib/max_number.rb
with your code. When you're ready to test again, run comet test
to see if your implementation is correct and to move onto the next failing test:
$ comet test
.F
# Test failures here ....
Finished in 0.00103 seconds
2 examples, 1 failure
Now that the first test is passing, the second test is failing. Repeat the process of fixing the broken code and running the test suite until all of the tests are passing:
$ comet test
.....
Finished in 0.00265 seconds
5 examples, 0 failures
When all of the tests are passing, you can submit your solution with the comet submit
command:
$ comet submit
Submitted solution for max_number.
Once you've made a submission you can view it on comet.launchacademy.com. You can, and should, also view our example solutions.