Lessons on Rails

Spent a not-very-fun day today playing around with Rails, Cucumber and their friends. I hope I learned something, because otherwise my output of today is decidedly minimal. These are some things I picked up, in the hope that they prove useful to someone else.

  • Don’t put both webrat and capybara in your Gemfile. They both define a visit method with different behavior. I had to search long and hard until I happened upon a discussion that clued me in.
  • Upgrading to the latest, greatest is very exciting, but if you pull in Rails 2.3.2 as an update, that’s what your installation will default to. This makes your app really unhappy if it’s based on Rails 3. Enforce your expectations by putting gem 'rails', '>= 3.0.0' in your Gemfile.
  • Another way to get bitten by upgrades is finding out that the Rake developers took their Domain Specific Language definition private, leaving the rest of the world in the cold. The symptom is that Rake suddenly won’t do anything but emit rake aborted! undefined method `task' for #. Until the world catches up, you’ll need to put a small hack in your Rakefile.
  • Ubuntu Linux’ package manager installs Ruby 1.8.7 as ‘ruby’, but Ruby 1.9.1 as ‘ruby1.9.1’. This is a pain, especially when you want to work on your code on several different systems. Fortunately, a post on an Ubuntu forum explains how to use their update-alternatives system to pick one over the other.
  • When you use the Debian apt Ruby package, you’ll find that Ruby Gems get installed in /var/lib/gems which is not bad in and of itself, but to use the binaries like rake, cucumber and rails itself, you’ll want to put /var/lib/gems/1.9.1/bin on your PATH.
  • You’ll find that this Debian/Ubuntu ruby1.9.1 package actually contains 1.9.2p0 (as of this writing).

Now that this is out of the way, I hope to have some fun with Behaviour Driven Development. Hope the development behaves better than the underlying tools did today.

Be Sociable, Share!