https://github.com/davidegrayson/kata-template-ruby-rspec-watchr
Template for test-driven development katas integrating Ruby, RSpec, and watchr.
https://github.com/davidegrayson/kata-template-ruby-rspec-watchr
Last synced: 6 months ago
JSON representation
Template for test-driven development katas integrating Ruby, RSpec, and watchr.
- Host: GitHub
- URL: https://github.com/davidegrayson/kata-template-ruby-rspec-watchr
- Owner: DavidEGrayson
- Created: 2012-09-15T21:56:51.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-09-18T16:10:17.000Z (over 11 years ago)
- Last Synced: 2025-02-14T10:09:42.066Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 152 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
Awesome Lists containing this project
README
h1. Kata Template for "Ruby":http://www.ruby-lang.org/en/ + "RSpec":http://rspec.info/ + "watchr":https://github.com/mynyml/watchr
This is a set of files that makes it easy to get started doing a "test-driven development":http://en.wikipedia.org/wiki/Test-driven_development "coding kata":http://codekata.pragprog.com/ in the "Ruby":http://www.ruby-lang.org/en/ language, using "RSpec":http://rspec.info/ as the testing framework, and using "watchr":https://github.com/mynyml/watchr to automatically run the tests whenever you change your code.
!http://www.davidegrayson.com/keep/kata-layout-thumb.png!:http://www.davidegrayson.com/keep/kata-layout.png
h2. Getting Started
First, clone this repository (or one of its forks) to a new directory named after the kata you want to do. For example, if you were doing a kata about tennis, you could run:
git clone git://github.com/DavidEGrayson/kata-template-ruby-rspec-watchr.git kata_tennis
You will need a few gems to use this template. The easiest way to install them is to go into the new directory, run @gem install bundler@, and then run @bundle@; this will install all the gems listed in @Gemfile@. What version of Ruby you use, and whether or not to use "RVM":https://rvm.io/, are decisions that are up to you.
Next, open @spec.rb@, and @kata.rb@ in a text editor. These two files are where you will write your specs and your code, respectively.
You can run the specs by running @rake@ at the command line, but you should really run @rake watch@: this will use watchr to automatically run the specs whenever any ruby files in the directory change.
You can run @rake -T@ to see what rake tasks are available.
h2. Managing multiple attempts with git
If you will be presenting your kata to an audience, you should practice it multiple times. I like to use "git":http://git-scm.com/ to manage the multiple attempts. That way you can easily keep the code from all of your attempts and compare them.
Before each attempt, you can run @git checkout -b tryN master@ to create a new branch named @tryN@, where @N@ is the number of this attempt. When you have completed your attempt, run @git commit -am@ to commit your changes.
To see the differences between your current set of files and a previous attempt, run a command like @git diff try1@. To see the differences between two attempts, run a command like @git diff try1 try2@.
h2. Test-driven development tips
* Repeat the "Red-Green-Refactor" pattern:
## Write a new spec -> test results turn red.
## Improve your code -> test results turn green.
## Refactor your code to make it better without breaking the specs.
* Only write enough code to make your tests pass.
h2. Presentation tips
* *Practice your entire presenation several times beforehand, speaking out loud to yourself.* This is the most important tip.
* Practice keyboard shortcuts so that you can give most of the presentation without moving your hand to the mouse.
* Favor typing code instead of pasting or uncommenting.
* Figure out how much time is allotted to your presentation, and have a timer running while you practice. It is good to leave time at the end for questions and feedback, and certain groups will expect that.
* Hide the OS's bars at the top and bottom to make more vertical room for code.
* Choose the window layout carefully. I really like the layout shown in the picture above because it allows you to see the specs, the code, and the test results all at once. Positive test results are easily identified without switching windows. A quick _Alt+Tab_ lets you see the full output of the specs when there is an error.
* Set up everything as much as possible before your presentation begins.
* Use a text editor that supports Ruby syntax highlighting.
h2. More Resources
* Jason Arhart's "shuhari":https://github.com/jarhart/shuhari/tree/master/lib/shuhari gem. Shuhari generates new projects for doing TDD kata with Ruby+RSpec+Guard.
* "RSpec documentation":https://www.relishapp.com/rspec
* "Ruby language documentation":http://ruby-doc.org/