Resolving Cucumber step ambiguities

Following the latest campaign against imperative Cucumber stories in favour of declarative stories (see especially Dan North’s great article on domain languages), I’ve been trying to get more naturalistic language into my stories. However, it becomes very easy to run into step ambiguities, something that Cucumber can try to handle on its own with --guess, but that I’d rather just resolve for it instead.
Continue reading “Resolving Cucumber step ambiguities”

Always define controller action methods in Rails 3

This morning was spent puzzling over a strange hard-to-reproduce Cucumber test failure in a project I have been upgrading from Rails 2.3.x to 3.0.3. It was only occurring after certain steps had been taken in previous Scenarios, and not when the failing Scenario was run on its own.

The solution was to explicitly define the controller action’s method in the controller. So the question to the world is: what changed, ActionController or something in the Cucumber chain?

ActiveRecord errors full_messages i18n incompatibility

If you’re running a Rails 2 app on a system with the latest i18n gem, ActiveRecord’s object.errors.full_messages spits out the string “{{attribute}} {{message}}”. You might notice that this is the old interpolation syntax for internationalisation in Rails 2. The latest i18n gem requires the %{} syntax. Sticking this into config/locales/en.yml fixed the problem for me, and future-proofs an app for when you accidentally upgrade the i18n gem on your production server:

Notes on a Rails 3 upgrade

Most scary output from console is warning rather than error.

RSpec 2 doesn’t have have_tag method. Now using webrat’s have_selector.

Plugin to help with upgrade only relevant to Rails 2 project, which seems silly.

Should use ‘extend ActiveModel::Naming’ in non-ActiveRecord classes used with view helpers that do record introspection e.g. form_for.

right_aws gem clobbers ActiveSupport 3, must use mikel fork

cucumber wasn’t following redirects. used this fork of webrat.

Builder needed requiring in application_helper, as I was using it to build markup.

Machinist 2 is a big change, but probably worth it. Cucumber needs database

Strange problem with matcher. I’d written matcher to allow ‘blah.should save’,
which clobbered ActiveRecord’s actual save method! Very specific, but worth
checking if you’re doing anything funky like that.

Routes were a breeze.

Array#sample rather than Array#rand

spec.opts now .rspec in Rails.root or ~/

Liking the enforced declarative style for validations.

email_spec had changed, features needed upgrading

#fullpath instead of #request_uri

Write more blog posts in shorthand!

Cheffin ain’t EZ for beginners

When I first set out to learn Chef I found that most of the blog posts, tutorials and even the Opscode Help pages themselves were a bit difficult to understand, to say the least. The ontology surrounding Chef is pretty hard to grasp for beginners: Resources, Clients, Nodes, knife, chef, Chef Server, Shef, Cookbooks, Recipes and so on. What I really needed when I started out was a specific walk-through of anything so long as it worked. And a lot of stuff doesn’t.
Continue reading “Cheffin ain’t EZ for beginners”