The Princess and the Pea, as a Cucumber Feature

1 06 2010

Kent Beck tweeted:

User story: “As a princess I want to confirm my royalty so I get bruised after sleeping on 40 mattresses over a pea”. Just tell real stories”

That sounded so much like a Cucumber feature that I decided to write it as one:

Feature: Physical Sensitivity
  In order to confirm my royalty
  As a princess
  I want to be very delicate

  Scenario: 40 mattresses on a pea
  Given there is a pea on the bed
  And there is a stack of 20 mattresses on the pea
  And there is a stack of 20 featherbeds on the mattresses
  When I try to sleep on top of the stack of featherbeds
  Then I should not be able to sleep


How to make Machinist and Autotest coexist

23 03 2010

If you’ve tried to use Machinist and autotest (part of ZenTest) you have probably seen this exception that prevented you from using it:

`method_missing': No sham defined for name

It’s discussed in the machinist Google Group as well.

It’s because of a wacky hack that’s part of Machinist that overrides Module.name so you can do Sham.name, but ZenTest expects Module.name to do what it does normally.

I have a fix for this.
Read the rest of this entry »



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 »