Ruby, Linux, Autotest, Rspec 2, Cucumber

Update: I’ve moved on to using Guard

Of the posts I’ve written this article about Rspec, Autotest, etc. has been one of the more visited. Time to update that ooold information.

If you don’t know what any of this is, the idea of Autotest is to get a test suite to run continuously in the background and provide ambient notifications about the failure/success status whenever a file is saved. You get feedback as soon as you break your test suite. The Linux part of this post involves getting Linux to pop up an on-screen display listing number of failed tests.

Cucumber is a BDD (Behavior-Driven Development) tool where you write out the features in plain language but then parse that natural language with regexps to pin tests behind it (called step definitions).

Rspec is a nice expressive test assertion library that can be used both in Cucumber feature step definitions and for traditional unit tests.

The process is much faster and cleaner now due to better gems and the convenience of Bundler. I’ll update with details about non-Rails projects.

The Gemfile section (note autotest-standalone and autotest-notification:

group :test do
  gem 'rspec'
  gem 'rspec-rails'
  gem 'cucumber'
  gem 'cucumber-rails'
  gem 'database_cleaner'
  gem 'autotest-standalone'
  gem 'autotest-rails'
  gem 'autotest-notification'
end

Setup commands:

# install the gems of course
bundle install
# steps for Rails
rake generate rspec:install
rake generate cucumber:install
# complained if I didn't do this
rake db:generate
# Do some magic for the notifications plugin
an-install

Then to run the tests:

export AUTOFEATURE=true; autotest

It’s working for me on Ubuntu 12.04.

Installing Ubuntu Pangolin on Beagle Bone

Just a quick note if you’re like me and you want to put Ubuntu on your Beagle Bone. The Beagle Bone is a sweet little palm-sized motherboard/processor guy that’s nice for little hardware projects. It comes with the Angstrom operating system loaded onto the SD card. This operating system was fine for initial development but I ran into an issue where I couldn’t leave a server to run and log out. If I checked back the server was always dead no matter what I did to detach it (maybe it was just pegging itself and restarting). So I wanted to see if Ubuntu would handle any better.

Anyways, I kept trying to just flash an image from the official Ubuntu page onto an SD card and boot it, but it wasn’t working. Then I saw that there is a script that does all the work for you mentioned on this page:

http://elinux.org/BeagleBoardUbuntu#Canonical.2FUbuntu_Images

Works like a charm, and Ubuntu does seem to be more stable than Angstrom on the Beagle Bone. Thanks to the author of the script, Robert C. Nelson.