Software
Rails application testing, top to bottom
Intro to a mini-series of articles with advice and pointers on practical, pragmatic testing for Ruby on Rails applications, based on my recent WellRailed presentation on the subject.
Rails testing miniseries part 2: What we want to test
Before we can get stuck into how to test each bit of our application, we need to be clear about what we need to cover.
Rails testing miniseries part 3: MVC testing
In MVC testing we test that each of parts of our application behave. Testing them separately makes our tests faster to write, faster to run, and reduces rework when we make changes to the app. Covers when to write the tests, and Test::Unit vs. RSpec.
Rails testing miniseries part 5: Controller testing
Setting the PATH variable the Mac OS X way
Mac OS X has a nice extensible way to add things to your PATH
environment variable using /etc/paths.d
.
Macports FreeImage patch for Leopard
Mac OS X open-source suffers from a lot of users and not a lot of contributers. You can whine about it, or you can help :). I've created a simple patch for the problems compiling the FreeImage macport on leopard, removing the need for the workarounds.
Installing ruby postgres and mysql gems on Leopard
Leopard comes with ruby preinstalled. Most of us use macports to install postgresql & mysql for use with rails, but if you use macports to install their ruby bindings then it will build it's own ruby too. That works, but here's how to compile them if you'd prefer to stick to the stock Leopard ruby.
Fixing the postgresql initdb fatal shared memory error on Leopard
When doing the post-install setup of postgresql default database using initdb, you may hit a fatal error due to the shared memory sysctl limits being too low by default.
Ruby memcache-client reconnect and retry-once patch
A big problem we hit with the Ruby memcache-client library (1.5.0) is that if the memcache server connection dies, it leaves the mongrel permanently broken. I've written a big patch to refactor it to reconnect properly and also retry the request (once) to give it a fresh start.
Changing system user account homedirs on Mac OS X
Changing the homedir for a hidden user account (eg. ‘postgres’ on my system) on Mac OS X is a bit less obvious than it is on Linux; you use the Directory Services utility instead of directly editing a file like /etc/passwd.
Selenium RC proxy chaining
Looks like I'm not the only one who needs to chain the Selenium RC proxy to another HTTP proxy. The docs are misleading, here's how to do it.
Selenium RC Firefox 2 support on Ubuntu Hardy
You may find after upgrading your Ubuntu boxes to Hardy Heron that Selenium RC stops working with Firefox. Here's how to fix it.
CruiseControl.rb git support patches
I've published a set of patches for CruiseControl.rb to fix up some issues with its' git support, and add full log parsing including messages and changesets, so your notifiers etc. can show the full info as for SVN. You can grab my patches from the Lighthouse ticket or pull from my github master. Thanks to my client Youdo for supporting this work!
Multiple IPs with Xen vif-route
There's a small issue with bringing up Xen dom-Us with multiple IPs bound to an interface if you're using routed networking (vif-route) instead of bridging. There's an easy adjustment to fix this which works fine for me.
Selenium RC Firefox 3.0 support on Ubuntu Hardy
If you've upgraded Selenium RC to the latest build you may be disappointed to find that while it supports Firefox 3 now, it can't start Firefox 3 “out of the box” on Ubuntu Hardy. Easy to fix.
Rails 2.1 eager loading conditions hash bugfix
I've created Rails lighthouse ticket #1101 for a blatant 2.1.x bug breaking :including of associations that have :conditions hashes. My patch is on the ticket. Remember to +1 it so it gets merged.
Rails 2.1 eager loading doubleup bug
I've created Rails lighthouse ticket #1110 for another bug in the new 2.1.x association preloading code that was causing some has_manys to get loaded with two copies of each record in the collection (and less seriously, double SQL loads of all types of collections). The problem turned out to be triggered by associations that have :includes defined on them themselves when the :includes are also supplied in the find call. My patch is on the ticket. +1s welcome :).
ERB comments in Ruby 1.8.7
After upgrading my server to Ubuntu Intrepid I found that this Rails site's layouts broke. The problem is this issue resulting from a ERB code change in Ruby 1.8.7: if you put a # Ruby comment in a one-line <% %> block, all the content up to the next %> that's on a subsequent line is ignored.
db:schema:dump after db:migrate:redo Rails patch
I've submitted another patch to Rails for a minor-but-annoying bug – if you use db:migrate:redo you'll find that it does migrate correctly but the schema dump afterwards doesn't work, so db:test:prepare clones the wrong structure (for example). The patch fixes things so that second and subsequent db:schema:dump invocations work properly. Testing and +1s, as always, very welcome.
Macports tsung build
The macports build of tsung is currently failing here because the SVN checkout is from an HTTPS url with an invalid certificate. I've submitted a Portfile change to use the HTTP tarball, which fixes the problem.
Web Directions Survey
This survey of web developers from the end of 2008 by Aussie-based Web Directions South gives an interesting snapshot of what people are using, somewhat bent towards what people are using in Australia and New Zealand. Brief summary:
script/dbdump command for Rails
I've just published a tiny Ruby on Rails plugin that adds a script/dbdump command. Like script/dbconsole, it reads your database configuration from config/database.yml and runs the appropriate mysql/postgresql/sqlite program – but rather than running up a database console it does a database dump. See the README at the above page re password options.
Rails Range conditions patch
I've submitted a patch to add support for Ruby's end-exclusive Range objects (created using … instead of ..) in ActiveRecord find :conditions hashes. This is really useful if you want to break apart a series of objects on something like a date-time field, which doesn't quantize exactly to integer values (on all databases) and so can't be handled using non-exclusive ranges without overlaps from values exactly on the boundary.
Rails columns on demand plugin
I've extracted out the code I was using to lazily load large BLOB/TEXT columns in one of my projects, tidied it up to take advantage of a refactoring in Rails 2.2.2 (cheers Koz) and improve its semantics, and released it as the columns_on_demand plugin.
When can I use...?
I heart the When can I use page, which is basically a filterable inverted index for all the current-gen and next-gen browser features we web devs are waiting for are available in all the big browsers, so you can find out at what point you can use them on their own, and how much sooner you could get there with shims and workarounds. Very handy.
Security FAIL
People really do fail at C. From Joy Marie Forsythe via ACM RISKS:
NIST is currently holding a competition to choose a design for the SHA-3 algorithm. The reference implementations of a few of the contestants have bugs in them that could cause crashes, performance problems, or security problems if they are used in their current state. Based on our bug reports, some of those bugs have already been fixed.
SAVE
It's been years since I read slashdot, but occasionally you run into articles with some real gems, like this comment on an article about an OS that's half like one I want to build (and half really not, but that's another story):
Communicative hosting companies
Looking around at a number of hosting companies recently it was great to see some positive examples of how you should communicate important permissions and restrictions to your (potential) customers sticking out from the usual pile of deliberately obscured limitations and unmanageable legalese we've come to expect from the world.
Bulletproof Javascript detection
You may have to be a programmer to understand why this is tragically funny, but the Bulletproof Javascript detection post Mog linked me to is, well, special. In the short-bus kind of way.
ARC caches
I find it very frustrating when the operating system I'm using – OS X, Linux, and Windows all do this – throw out the useful contents of the filesystem caches to fill them up with the contents of the very large files I frequently work with (sometimes even swapping out applications to get more space for memory cache!) – even though these files are almost always used just once.
Installing PostgreSQL and Mysql and the Ruby gems on Snow Leopard
Things have gotten a lot simpler since the write-up I gave for Leopard.
Again, Snow Leopard comes with Ruby preinstalled, and I strongly recommend that you stick with that version rather than using the macports Ruby – no need to have two versions on your system.