ruby, rails, textmate, automation, etc.

Integration Testing for Multiple Web Applications – Introducing Integral

Posted on November 11, 2008

I’ve recently been developing a Rails app that relies on a database that is maintained by another team as part of a different application. As you can imagine, unexpected changes to the database schema can bring our Rails app to it’s knees if they’re deployed to the live server before our application is updated.

So far we’ve been lucky, but the issue has been at the back of our minds for a while. So this week I sat down and cooked up a solution, and we’ve called it Integral.

Integral consists of some Thor tasks that:

  • Run tests on your test server.
  • Keep track of which versions of your applications work well together.
  • Can be integrated into your deployment recipes to ensure that deploying an app should never break your live server again…

All the Integral code is on github, and I’ve written some fairly extensive documentation on the Wiki. Please try it out, give us some feedback, fork it, burn it, give us some feedback, etc. etc.

Installing merb with thor

Posted on October 05, 2008

Update (22 October): Things move very fast around here – the merb.thor file has been overhauled and now all you have to do to get the latest edge is download a single .thor file and run one command.

Matt Aimonetti wrote a neat post on installing merb edge with thor. Thor seems to have become the defacto technique for installing merb edge these days, and I’m going to give it a go in preference to installing merb with sake, as I had been doing.

Since Matt wrote his article the merb.thor file underwent a serious overhaul during the sprint at MerbCamp – what you need to do these days is quite a bit simpler:

curl -L http://merbivore.com/merb.thor > merb.thor
sudo thor merb:stack:install --edge

The source code for all the Merb gems will be checked out into a directory called ./src.

To get the full low down on how to use Thor with Merb, head over to the Thor Howto on the excellent new Merb wiki.

Building do_mysql on a 64-bit Mac

Posted on October 02, 2008

Whilst installing merb with edgy I’ve had run into some trouble building the do_mysql gem on my Macbook Pro. It’s a 64-bit machine, so I installed the 64-bit version of MySQL, and that was my first mistake…

merb and DataMapper on the edge

Posted on July 14, 2008

I’ve just started writing a new app with merb and datamapper, so decided to start out on the edge. The preferred way to do it these days is with sake, a tool for running system wide rake tasks. It’s rather neat, and should (in theory) have made my installation of the edge versions of merb and datamapper extremely easy.

I did hit a couple of issues running them on Ubuntu 7.10, hence this article

Testing Merb controllers with RSpec

Posted on April 14, 2008

I’ve been trying out Merb recently, and I’m liking it. However, I’ve spent a lot of time stumbling around the interweb looking for examples of what I’ve been trying to achieve. So far I’ve been coming up short. The Merb API docs are good, but you can’t beat a good example.

So I’ll be recording my little revelations as they happen. First up - how to test a controller.

Searching associations in DataMapper

Posted on April 12, 2008

One of the first things you discover when you start playing with DataMapper is how to specify conditions when searching a database table. This will get you all the chocolate biscuits:

Biscuit.all(:chocolate => true)

After I’d read some of the docs I hoped I might be able to use a similar approach to search my associations. Given that a packet has_many biscuits I hoped I’d be able to do something like this:

packet.biscuits(:broken => true)

I was wrong, and you’d probably only expect that to work if (like me) you hadn’t done much with DataMapper yet. Still, you might.

In the current version (0.3.0) you do it like this:

Biscuit.all(:packet_id => packet.key, :broken => true)

That’s fine. I dare say associations will grow the ability to be searched in due course, but in the meantime, maybe that’ll help clarify it for somebody…

If you’re interested in DataMapper (and merb?) then you might want to check out the open source book on the subject: Life On The Edge With Merb, DataMapper & RSpec.