RSpec Presentation
This is a zip of my RSpec presentation from Desert Code Camp this past weekend.
It includes all of my slides in the PDF, plus all of the supporting code.
Enjoy!
A father doing Ruby on Rails and RSpec development
{ Category Archives }
This is a zip of my RSpec presentation from Desert Code Camp this past weekend.
It includes all of my slides in the PDF, plus all of the supporting code.
Enjoy!
I couldn’t remember where I got this from, so I am posting it here. If anyone can help me figure out where this comes from I would love to give proper credit.
So I’ve finally gotten myself a mac. Well, actually my boss got one for me, but you get the point. Anyways, my coworkers and I were having problems with Autotest, RSpec, and Growl before the recent release. However, since 1.0.8 is a new version, we decided to try again. So far it’s worked. So with a big thanks to Daniel Fischer, I’d like to write up how.
Here’s how. First, get your essentials:
Second, download the following pictures:



Third, copy the following into your .autotest file:
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{ msg.inspect} #{title} #{stick}"
end
Autotest.add_hook :ran_command do |autotest|
output = autotest.results.grep(/\d+\s.*examples?/).last.slice(/(\d+)\s.*examples?,\s(\d+)\s.*failures?(?:,\s(\d+)\s.*pending)?/)
if output =~ /[1-9]\sfailures?/
growl "Test Results", "#{output}", "~/Library/autotest/rails_fail.png", 2, "-s"
elsif output =~ /pending/
growl "Test Results", "#{output}", "~/Library/autotest/rails_pending.png"
else
growl "Test Results", "#{output}", "~/Library/autotest/rails_ok.png"
end
end
end
If you don’t already have one. Just save it to ~/.autotest. Replace the three image locations with your downloaded ones, and you should be good to go!
So on a reading trip about testing, I read about how certain parts of the aerospace industry practice TDD on the order of 4-to-1. Meaning 4 tests for every part of the system.
This got me thinking. We should start using Comment Driven Development*. How many lines of comment could we get in for each line of code. Just imagine how clear our code would be.
Example
Take this example:
jonny.go_to_store
Now, sure that is clear, but it could be better. Here it is with 100% CDD Coverage:
#Send jonny to the store
jonny.go_to_store
Even better is 200% CDD Coverage:
#Send jonny to the store, three blocks north and one block tothe left.
#he should get eggs, bacon and milk while he is there.
jonny.go_to_store.
Get the ruby pack Here
Get the controller pack here
Get the models pack here
Get the validation pack here
Get the render pack here
Get the environment pack here
Get the migration pack here
Get the testing pack here
Get the rspec pack here
Get the rhtml pack here
Finally, documentation as promised. You can get the entire set of packs here as one zip file with all of the individual xml files inside. Or you can just download this zip and get it as two files. One for RHTML, and one for Ruby.
I’d also like to share my script for making this documentation. It should work for any Eclipse template file. Change the extension to .rb, and drop it in the directory with the xml files. Run it and it should create a txt file for each xml file in the directory. The text file is in textile and it is simply a h2 followed by a list of the templates. Enjoy