Using RVM to install REE 1.8.7-2009.10

16 03 2010

I’m trying out Ruby Version Manager this week, and my first impression is that this is some cool technology. But I wasn’t able to figure out how to get it to install an older version of REE to get around this bug (the “Marshal.load reentered at marshal_load” issue).

Igor P’s solution is correct (just install REE 1.8.7-2009.10), but it took a little fiddling to figure out how to get RVM to use the older version of REE. Here’s how to do it:

cd ~/.rvm/archives
wget -q http://rubyforge.org/frs/download.php/66162/ruby-enterprise-1.8.7-2009.10.tar.gz
rvm install ree-1.8.7-2009.10


Proper Error Handling in Rails Controllers

27 07 2009

Rails controllers can get out of hand if you’re not very careful. Skinny Controller Fat Model is a great start. But what about handling errors? Isn’t it enough to just let Rails catch your exception and show a 500 Server Error page?

No, it’s not. Falling back on 500 Server Error for everything outside of the “happy path” through your code is sloppy coding.
Read the rest of this entry »



A Cucumber step to test for a YM4R Google Map

27 07 2009

I had some problems with a view in a Rails app that was conditionally hiding a Google Map that was generated using the YM4R plugin. I don’t usually test views in unit tests, and this logic depended on a particular situation with the data behind the view, so I decided that this would be a good candidate for a Cucumber feature.

Here’s the Cucumber step implementation I wrote.
Read the rest of this entry »



Fancier Stubbing of GeoKit for Rails unit tests

23 07 2009

I’m working on a Rails app that uses the ym4r_gm plugin, getting Google to do the geocoding for Thentic. I liked the idea of stubbing the web service call, because all those calls to an external service add up to over 20 seconds of test suite run time(!). That’s almost half of the 50 second run time of my unit tests (and 50 seconds is much too long for a unit test suite).

I found a good starting point at geokit stubbing for faster tests. I also wanted a way to stub a geocoding failure, and a way to prevent any unit tests from using the real geocoding web service.

Here’s how I did it.
Read the rest of this entry »



Things I had to fix for Rails 2.2.2

29 11 2008

The new features in Ruby on Rails 2.2.2 have been well documented, and I’m looking forward to using several of them on WhatYouAte.com. If you’re reading this you probably are too.

However, if you’re upgrading an existing project and you’re sticking with official releases (as opposed to edge Rails) like I am, your code probably needs some tweaking to work with Rails 2.2.2. Mine certainly did. Although there were a lot of failed tests with ugly stacktraces, there were only a few API changes in Rails that needed to be accomodated to fix them all. Here’s a list of the changes that broke my app, and what I had to do to get it working again.
Read the rest of this entry »