Caius Theory

Now with even more cowbell…

End Of An Era

I remember watching Steve Jobs' commencement speech for the first time and being fairly touched by the three stories he told in it. The major one that resonated with me at the time, and has since made more sense to me, is the first story he tells about joining the dots later on when you're looking backwards. To quote from it:

Of course, it was impossible to connect the dots looking forward when I was in college. But it was very very clear looking backwards ten years later. Again, you can't connect the dots looking forward, you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future.

It made me think back to a time when I was a teenager and someone far older and wiser than me told me one way to think about the future and how what we do today affects where we end up. He described it as holding a piece of string in your hand, with the other end dangling free. The end of the string not attached to you is the future, and where you're holding it is the present. As you do things in life your hand moves around, flicking the string around and amplifying the movements of the present in the future.

I think what he was trying to impart by telling me that story was to be careful not to do anything too extravagant in the present (like get expelled from school for instance), so as not to affect the future too much. Which I never really took on board at the time, but now I look back at the dots of my (some would say) rather short life so far, and connect them to see how some things influenced other things and how everything works out in the end. But that sometimes you need to push yourself or do something unexpected to get there.

Looking Backwards to go Forward

When I look back over the last few years of my life, I find the dots quite amazing to connect. First there was BarCamp Sheffield 2007 where I met Dom, and there was Twitter and BarCamp Manchester & Leeds where I met geeks like Rahoul, John and Jeremy both online and offline. And then in June 2008 I moved to Leeds, sharing a house with Dom and quite quickly ended up being hired into what was basically my dream first job at Brightbox.

And that's where I've been working for the last 1198 days, having far too much fun, solving weird, wonderful and sometimes downright frustrating problems, all with fantastically awesome and hilarious colleagues. And working on a massive variety of things, from tiny utilities to the newly launched Cloud Platform.

And today I flick my wrist ever so slightly more than normal by leaving Brightbox, without really knowing where the future end of the string will eventually end up, but knowing that I'll look back in a few years and see dots connected that I can't imagine today. I truly don't think I could have had a better job to start off as a professional geek, and especially want to thank John and Jeremy for hiring me and helping me start my career in the best way possible.

As for my next challenge, I'm solving interesting problems in the online advertising world with Cristiano, Dom, Melinda and Rahoul. And we're bloody amazing together. :-)

Adding XHTML output validation to Cucumber stories

At the 2009 Barcamp Leeds I attended a talk by Neil Crosby where he talked about automated testing, and about how he felt there was a gap in everything that people were testing. Everyone has unit tests, and people are doing full stack testing too, but no-one (so he feels) does XHTML/CSS/JS validation as part of their automated test suite. And certainly from what I've seen on the mainstream Ruby site's about testing, I agreed with him.

So after his talk I had a quick look at his frontend test suite, and started wondering where exactly I would fit frontend validation testing into my workflow. Would it be part of my unit tests (RSpec), or part of the full stack tests (Cucumber)? As you've probably guessed by the title of this post, its ended up going into my cucumber tests. Since the initial play its been something I've mused about occasionally, but not something I've actively looked into how to implement as part of my test workflow.

Fast-forward a few weeks from Barcamp Leeds and I see a news article in my feed reader entitled "Easy Markup Validation" which gets me hopeful someone's solved this frontend validation thing easily for Rubyists. A quick read through and I'm sold on it and installing the gem. Opened an existing project I'm working on which has a fairly extensive test suite (both unit tests & full stack tests) and tried to slot the validation into my controller unit tests.

Problem with doing this is by default RSpec-rails doesn't generate the views in your controller specs. At that point I realised I was already generating the full page when I was doing a full stack test using culerity and cucumber. So why not just add a cucumber step in my stories to validate the HTML on each page I visit? Mainly because its not enough of a failure for this app to have invalid XHTML markup. Having valid markup would be nice, but I'd rather have it as a separate test to my stories in some way.

Currently I just do that by only validating if ENV["VALIDATION"] is set to anything, so a normal run of my cucumber stories will just test the app does what its supposed to do. If I run them with VALIDATION=true then it will check my markup is valid as well.


require "markup_validity" if ENV["VALIDATION"]


Then %r/the page is valid XHTML/ do
  $browser.html.should be_xhtml_strict if ENV["VALIDATION"]


Feature: Logging in
  In order to do stuff
  As a registered user
  I want to login

  Scenario: Successful Login
    Given there is a user called "Caius"

    When I goto the homepage
    Then the page is valid XHTML

    When I click on the "Login" link
    Then I am redirected to the login page
    And the page is valid XHTML

    When I enter my login details
    And I click "Login"
    Then I am redirected to my dashboard
    And the page is valid XHTML

Now when I run cucumber features/logging_in.feature, it doesn't validate the HTML, it just makes sure that I can login as my user and that I am redirected to the right places. But if I run VALIDATION=true cucumber features/logging_in.feature, then it does validate my XHTML on the homepage, the login page and on the user's dashboard. If it fails validation then it gives you a fairly helpful error message as to what it was expecting and what it found instead.

From a quick run against a couple of stories in my app I discovered that I've not been wrapping form elements in an enclosing element, so they've been quickly fixed and now they validate. Now I realise this gem is only testing XHTML output, and doesn't include CSS or JS validation, but from a quick peek at the gem's source it should be fairly easy to add both of those in I think, although again they aren't major errors for me yet in this app.

The Shell Meme

I ran across The Shell Meme on Lincoln Stoll's blog, and figured I'd, uh, borrow it.

Run this command in a new shell:

history | awk '{ a[$2]++ } END { for(i in a){printf "%5d\t%s\n ",a[i],i} }' | \
  sort -rn | head

I get this as the output

379    git
221    cd
181    ssh
77    sudo
69    ruby
66    ls
34    rake
33    m
32    bb
31    m.

bb changes directory straight into my BrightBox source directory. m and m. are TextMate alias's to open files or directories in TextMate for editing.

When work just feels right

Much like Rahoul's post on knowing you're on the right path, I had that moment this morning whilst we were discussing a future feature for our control panel.

john: will I be able to superpoke our customers?
john: is that in the spec?
Jeremy: "John made server10 a zombie"
Caius: "server10 zombified server9"
Jeremy: "David has poked server19 19234 times"
john: server16 messaged David "My disk is filling up and I have files I need to put somewhere, please help!"
Caius: "Rahoul ended his friendship with server15"
David: "server02 is now married to server05"
Rahoul: server10 has sent you 12 videos of a fat man eating a cake
David: server11 joined the group "KVM ftw"
Caius: "server16 threw a sheep at server15"
john: server03 joined the group "Centos sucks!"
Caius: "server15 sent an emergency broadcast: physical movement detected"
john: storage03 has logged off
Caius: "x13 flew to the moon 0 times"
john: disk5 in storage02 is now a zombie
Jeremy: disk4 in storage02 is now a zombie
Jeremy: disk3 in storage02 is now a zombie
Jeremy: disk2 in storage02 is now a zombie
john: storage02 was sold on ebay by Jeremy
Caius: "john was sold on brightbox marketplace by storage5"

(In case you don't know, I work for Brightbox.)