Tim Harvey :: Blog

Icon

I help organizations who feel stuck

RVM installation of Ruby Enterprise Edition on Ubuntu Hardy

I decided to try out Rackspace Cloud for a new worker server that Am I Down needed. Since I wanted to keep the system tight on memory usage, I decided to go with Ruby Enterprise Edition. Unfortunately, I ran into a snag getting it installed via RVM (the terrific tool for running multiple versions of Ruby).

I kept getting this error after running “rvm install ree”:

Error running './installer -a /home/username/.rvm/rubies/ree-1.8.7-2010.01  --dont-install-useful-gems ', please check /home/username/.rvm/log/ree-1.8.7-2010.01/install*.log
There has been an error while trying to run the ree installer. Aborting the installation.

I couldn’t find anything on how to fix this as I poked around Google. Since I use zsh (via the amazing Oh My Zsh project), I figured that had to be conflicting with it. I did resolve one issue caused by the old version of zsh installed via “sudo aptitude install zsh” by compiling zsh from source (a newer version).

The Solution: Install Readline headers

But…back to the issue at hand. The solution became clear when I tried to install REE from source. The REE installer complained about missing “GNU Readline development headers”. Running the installation for readline fixed it.

sudo aptitude install libreadline5-dev

From there, RVM installed REE no problem.

Update (3/5/2010): Wayne, the author of RVM kindly wrote to me on Twitter within hours of this post to see if there was some working improperly with RVM. It turns out that I missed a clear set of instructions that indicated the need to install readline5 when using REE. Thanks Wayne!

Validate Ruby on Rails model entries with Cucumber

If you use Cucumber, chances are good that at some point in your testing, you needed to verify that a certain set of database records had been created. While this flies in the face of most BDD best practices, I’ve run into a few edge cases the last few months that required this level of minutia. Ideally, you’d use RSpec or Test::Unit for checking database/model level details, and let Cucumber focus on the higher level full stack checking.

In my case, I needed to verify that the admin tool I’m creating builds records necessary for the public side of the site (which hasn’t been built yet). There really wasn’t any visibility in the admin area to this data, except when it’s created. While I did have a solid set of RSpec tests for the model functionality, I felt it necessary to make sure those model methods were called correctly through the controllers and routing that went on.

As a result, I wrote this step:

Then /^I should find these "([^\"]*)" records$/ do |model_name, table|
  model_name.constantize.count.should == table.hashes.count
  table.hashes.each do |record|
    model_name.constantize.find(:first, :conditions => record).should_not be_nil
  end
end

You would use it in your Cucumber feature like this (intentionally bland example):

Then I should find these "Post" records
  | title          | permalink      | category   |
  | A blog article | a-blog-article | Technology |

The first row specifies the fields that will be used as conditions. The following rows will be used to search against. The step will make sure that at least record in the model matches. It will also verify that the number of records in the model matches the number of rows in the Cucumber feature.

Get updates in your inbox

Enter your email address: