RJS Assertions

For example, previously I was testing that when I entered the postcode for Buckingham Palace, the address would be filled for me:

def test_when_selecting_address_address_fields_populated  xhr :post, :fill_address, :selected_address => 1  assert_response :success  assert_equal "text/javascript",     @response.headers["Content-Type"]  assert /Buckingham Palace/.match(    @response.body  )end

Unfortunately, this relies on regular expression matching, there’s no guarantee that the address that’s recovered actually replaces the text in the address first line text box. Any number of templating problems could cause it not to be rendered correctly, and I’d end up with a broken app that wouldn’t necessarily have tests failing.

At the time I wondered about whether it would be possible to write code for the RJS emitted script as I did with the rest of Rails’ functional tests—using `assert_tag` etc.

Well thanks to RJS assertions I can now. The previous test now looks as follows:

def test_when_selecting_address_address_fields_populated  xhr :post, :fill_address, :selected_address => 1end

assert_response :successassert_equal "text/javascript; charset=UTF-8",  @response.headers["Content-Type"]assert_rjs_tag :tag => "input",  :rjs => {:block => 'originAddressEntry' },  :tag => "input",  :attributes => {    :id => "from_address_line_1",    :value => "Buckingham Palace"     }

Much better, it’s far more communicative and the intent is clear. It’s also much more natural when writing test first now—“I want some RJS script that’s going to update this block and I’m looking for a tag that looks as follows…”

In the above test I’m asserting that I’m replacing the `originAddressEntry` division with the emitted RJS script, and that I’m looking for an `input` tag, with the id of `from_address_line_1` that will have it’s value set to Buckingham Palace.

I really encourage anyone doing any RJS work to use the additional assertions, and check out Brasten’s blog post on the plugin. There’s no reason not to test your RJS controller code thoroughly now!

Pimped Snacks

Their previous entry was good but not quite big enough (picture to the left – the middle-sized Jaffa Cake is actually the regular sized ones you buy in the shops).

Compare it to the one I produced, as can be seen below. .

So, without delay, here’s how I did it.

Firstly, the cake. This was just a ‘vanilla’ Victoria sponge mixture, for which you need:

1. 4 eggs (medium or large)
2. 250g Caster Sugar
3. 250g Self-raising Flour
4. 250g Butter

Put all of that in a large mixing bowl and give it a good solid mixing, once it becomes a nice smooth texture, you’re done and ready to put it into something for it to bake in.

To achieve the round shape we needed, and since there were baking trays large enough for the ambitious project we were undertaking, we used the lid from a Le Crouse casserole dish. Once that was poured in, just pop it in the oven (at about 180 Celsius) and keep an eye on it.

To know when it’s ready to take out, pop a knife in the middle of it - if you pull it out and there’s gooey stuff on, it’s not done. Once a knife comes up clean it’s baked through and you’re good to go to the next stage - the jamming! Place it onto a cooling tray and get cracking!

For the orangey Jaffa centre that is the magic behind the Jaffa Cake, we used some quick-setting orange jelly. This involved boiling some water and putting the powder mixture in and stirring away. After a short while it went into a syrupy texture and we were under-way, we put it into a round tray to put in the fridge to set. About 20mins later we were done and could place the orange stuff onto the cake. The result is a sight to behold!

Once the jelly was on the top all we needed to do was cover it with chocolate, then decorate the chocolate a little with the same pattern on the jaffa cakes.

Melting the chocolate is an easy, albeit risky manouvre. You have to watch it like a hawk, but more importantly, don’t overdo it. We took our eyes off the prize and ended up just letting it bake almost. The result being a very gloopy solid chocolate mess that wasn’t going to spread anywhere. So, we set in rescue mode.

To rescue the chocolate, all you have to do is lovingly mix back in some cream or milk, slowly and over a low-ish heat. Eventually it’ll settle back down to a smooth consistency. Then cover it with chocolate, and set it up ready for the decoration by smooting it out as best you can.

Finally, all you need to do is add the hatching type effect and let the chocolate set for a little while.

The result is a monster Jaffa that positive eats all other Jaffa contenders. I’m not too sure of the dimensions but of course it dwarfs it.

All that’s left to do is taste it and check out your handy-work! After-all, there’s no sense pushing the boundaries without reflecting on your achievements!

As you can see, I was more than ready to tuck in. However, a fair bit of toffee, and chocolate tasting had taken its toll on me and I couldn’t manage much, but for ‘pimping’ its all about the looks.

Now, it wasn’t just me pimping snacks, we made a number of things at the same time (with all the photos from the evenings pimping are available in a set on Flickr) including a pimped Rolo, a pimped Kit Kat, and a failed attempt at pimping a Malteser. All in all, great fun, wonder if anyone could get these things into a record book!

If anyone has a go, let me know!

Exciting News

I will be starting my new job as a ThoughtWorker on the 2nd of May, a week Tuesday (tomorrow)!

I’m extremely happy to say that a couple of weeks ago I was offered a position as a developer at ThoughtWorks, working out of their Holborn office. It’s an incredible opportunity, one where I’m looking forward to learning a lot, and one that will hopefully prove extremely rewarding.

At the moment I’m going through a mixture of extreme excitement and incredible nervousness as the day nears, but I am really looking forward to it!

The whole process from original telephone interview through to further interviews and tests, and then subsequently offer was extremely quick (although extremely nerver-wracking). Mind you, a rather masochistic part of me actually enjoyed the interviews and tests. I also have to say that the people I met and interviewed with were absolutely brilliant—they really made me feel relaxed and comfortable, it didn’t feel like any other interview I’ve been to.

So, until the 2nd, time to get back to enjoying my last few days off (I’ve been catching up on some reading—I’m well under way with Domain Driven Design, an excellent book by the way, but I also have a few others stacked up).

Low Impact Tooling

I think I’ve finally come to grips with what I appreciate out of a development environment/toolset—it’s as low impact as possible.

By that I mean that it just augments what I’m attempting to do as a developer. Using Visual Studio is a really boring (and some would say even arduous) task without JetBrains’ brilliant ReSharper tool. Likewise, I appreciate the benefits of having the ability to run my unit tests without leaving the code view, or even having to run a build myself. Just right click on the test or fixture, and “Run Tests”.

Nowadays I develop Rails stuff almost exclusively on the PowerBook using TextMate (as seems to be the defacto standard for Rails developers). Tests are a cinch to add, and run (either by using the rake task, or Command-R inside TextMate itself).

The reason I bring this up is because I’ve been trying to get a decent process and tooling setup for developing in a TDD way with Flash. For anyone who’s not tried, it’s an absolute nightmare. For those who have, I feel your pain and seek your guidance.

Flash just doesn’t make a developers life easy, partly because it’s always felt a kind of bolt-on addition to make animation easier, but its just so painful trying to accomplish anything. To the point where I’ve spent a few hours trying to get AsUnit with Flash Authoring working that I’ve kind of given up. I’m sure it’s not AsUnits fault, but Flash just is not a nice place to be.

I’m hoping that someone who’s done/doing something similar can help?

Essentially I want a decent way to author some ActionScript classes that I can test with AsUnit. Or perhaps someone could suggest how to get Flash 8 working with AsUnit 2.7 on OSX?

My install seems to try and create an `AllTests.as` file in every possible place, other than my project folder—including OSX’s Applications’ pseudo-folders. When I create a test class it just seems to hang and Flash asks if I want to stop a long-running script.

Until then, I’m just in awe of how Subversion just works, and how low-impact tooling makes my coding life a more happy one.

Lighttpd and FCGI for Rails -- To Static or Not?

I’ve noticed a little instability with my setup recently, at present I have Lighty configured to manage the FastCGI processes itself.

The relevant part of my config looks as follows:

fastcgi.server= (".fcgi" =>("oobaloo.co.uk" =>  (    "socket" => "/tmp/oobaloo-lighttpd-fcgi.socket",    "bin-path" =>  "/var/www/servers/www.oobaloo.co.uk/current/public/dispatch.fcgi",    "bin-environment" => ("RAILS_ENV" => "production" ),    "max-load-per-proc" => 4,    "min-procs" => 1,    "max-procs" => 3,    "idle-timeout" => 90  ))

However, I’ve read people suggest that it’s better (when running more than one rails application) to instead use static processes, and there’s a page on the Rails wiki describing this setup.

So, I changed my Lighty config to the following:

fastcgi.server = (".fcgi" =>  ("localhost-7000" =>    ("host" => "", "port" => 7000,  "bin-environment" => ("RAILS_ENV" => "production"))),  ("localhost-7002" =>    ("host" => "", "port" => 7002,  "bin-environment" => ("RAILS_ENV" => "production"))),  ("localhost-7001" =>    ("host" => "", "port" => 7001,  "bin-environment" => ("RAILS_ENV" => "production"))))

and instead started the processes manually using the `spawner` with the following script:


www.oobaloo.co.uk/current/script/process/spinner \
-c ’/var/www/servers/\
www.oobaloo.co.uk/current/script/process/spawner -p 7000 -i 3’ \

However, I noticed that over time new processes were being created to handle `dispatch.fcgi` for the blog. This got to the point with about 6 or 7 processes that would choke the VPS and cause it to become relatively unusable.

Is this normal for other processes to be created? Under what conditions would additional processes be spawned?

Anyway, for the time being I’m back on Lighty managed processes—at least the number of processes remain static.

Excitement with some big news!

Things have been pretty quiet here ony my blog of late, but there has been a reason!

Approximately 3 weeks ago my position at Perfect Information was made redundant and I focused my time at looking for future employment, as well as finishing up a few small side projects I’d been working on.

I’m absolutely overjoyed to say that last Tuesday I was officially offered (and accepted) a developer position with ThoughtWorks UK, somewhere I’ve always had an urge to apply to, but had always been quite scared by.

An old colleague of mine joined and had always had great things to say about the place, so I thought I’d give it a go. Whilst out on holiday I had an email asking me to get in touch to arrange a phone interview. Since then I’ve been through the phone interview, coding test, 2 developer interviews, some more intelligence/aptitude testing, personality tests and a further interview with a senior manager. But I made it. I’m to become part of Roy’s Social Experiment.

I’m thoroughly looking forward to getting started. My first day will be on the 2nd of May, and I’ll hopefully also get the chance to post a little about starting as an experienced hire, and what it’s like to be a ThoughtWorker.

In the meantime I’ll be catching up on some reading, writing, and of course coding. In particular, something really good fun I’m putting together that I hope to have released before then!

Until then, time to open something fizzy and alcoholic!

Upgrading Typo and Rails

Firstly, I needed to get Ruby 1.8.4 compiled to upgrade my 1.8.3 release, as well as compile in support for Readline (since I posted about a problem I’d had with Rails’ console earlier without this):

cd ~/wget ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gzwget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.4.tar.gztar zxvf ruby-1.8.4.tar.gztar zxvf readline-5.1.tar.gz

cd readline-5.1./configure --prefix=/usr/localmakesudo make install

cd ../ruby-1.8.4.tar.gz./configure --prefix=/usr/local --enable-pthread\  --with-readline-dir=/usr/localmakesudo make install

That should update your version of Ruby, you can check all went well by running `ruby -v` and checking you see: `ruby 1.8.4 (2005-12-24) [i686-linux]`.

The next step was to get my server up and running with the latest code from Typo’s trunk (and place Rails 1.1 in the vendor directory—I wanted to leave my other applications on 1.0 for the time being).

To do that, I created a separate directory at the same level as my current Typo revision. Within the directory I also have a symlink named `current` that points to the revision I’m currently running from.

So, I ran the following:

cd /var/www/servers/www.oobaloo.co.ukmkdir trunkcd trunksvn co svn://typosphere.org/typo/trunk .

That should pull down the latest revision, I also then renamed the directory to indicate the revision that it corresponds to:

cd ..mv trunk trunk-983

Next, we need to place the Rails 1.1 release inside the Typo application’s `vendor` directory. This is apparently what is likely to be bundled into future Rails releases: everytime you create a new application via `rails myapp` it’ll copy the Rails source over for you.

So, I do the following (inside the `trunk-983` directory):

cd vendormkdir railscd railssvn co http://dev.rubyonrails.org/svn/rails/tags/rel_1-1-0/ .

Again, you’ll see a flash of info from Subversion letting you know it’s all been downloaded successfully.

Finally, I wanted to do the necessary database migrations so that my database schema is up-to-date. To make sure I didn’t lose anything I used `mysqldump` to backup the database beforehand (into a `db` folder I use for all my backups).

cd ../../dbmysqldump typo_production -u typo -p > typo-pre-983.sql

Check that the file was created with all the content, and then you can make the final step (running the Rails migration):

cd trunk-983rake migrate RAILS_ENV=production

You should hopefully see the migration stuff succeed, finally, you can switch the `current` symlink over:

rm currentln -s trunk-983/ current

And you’re off and running!

1..2..3.. you're back in the room!

After a few woes over the past few days all seems well again.

First, my email died—re-sending old emails, which, even after deleting boatloads just seemed to keep filling up my inbox. In an attempt to keep better track of things and provide a far better service I’ve switched to a new (and separate) provider. I’m going to see how it goes for a month and go from there. I ended up choosing one in the UK to provide a snappier IMAP experience.

If that wasn’t enough, the hostserver my VPS is on hit a ‘kernel bug’ earlier this morning and wiped me out for an hour or so, just as well I don’t host my own email!

So, if you’ve been trying to download code, read posts or contact me, that’s why I’d ‘gone dark’, but the LEDs are back on and blinking now!

Mint Follow-up

Firstly, one of my concerns was that I no longer had a way of viewing Pages per Visit, this was a great way of determining whether people navigated around my site having got here. For me this is important as if other people link to my posts, or are referred here through my comments to other posts/pages, they’re interested in what I have covered.

Mint has something similar to this (Total vs. Unique in it’s Pages panel), but the excellent Fresh View pepper let’s me visualise it. I can tell from the spikes (directly correlated to me making a posting (and receiving hits from referrers such as Planet Ruby on Rails and Developer Fusion) that there are more views per visit for that day, than a non-posting day. Leading me to believe that when other people find their way here (by way of Google, for instance) that they stick with the article they found. Perhaps making it easier to find related posts may encourage people to stay?

The brilliant Outclicks pepper also lets me see where people go afterwards, and the page they were on beforehand. It doesn’t really help me target posts better, but it does let me know that people are finding things useful, if not the things I directly write.

lets me know whether I'm doing relatively better, or worse, between two time periods. For me, this is weekly. I know that because I posted more times this week, I've served markedly more requests. A great encouragement to keep posting. However, what's more important is that I can see which posts are retaining popularity through being referenced elsewhere, or found by Google. If I can keep on finding interesting things to post about, perhaps people will stick around.

Overall, it’s feeling much better. I still miss a way of seeing the amount of time a user spends on a particular page. Google Analytics had a great page that could show you a breakdown of pages, based on pages people spent most time at, the average time a user spent on any given page etc. Very useful stuff. Perhaps I should look at the Pepper API and see whether I could do it. Unless someone’s seen something else to do it?

Have a good weekend!

Great Hosted Email Needed

My email seems to be going a little screwy right now (currently hosted by my old ASP.NET provider – CrystalTech). Their webmail has never been that great to use, and anti-spam/virus has also been a little flaky—I ended up just rejecting any emails with any attachments.

So, I’m now looking to find somewhere else to host my emails. I could move it onto my VPS, but I’d rather not have something as essential as email at the will of my tinkering! It’d also be nice to have really, really solid anti-virus and anti-spam protection that I just don’t have time to administer.

Essentially, I’m looking for something along the lines of MessageLabs, but usable (and affordable) for an individual. I also need IMAP (rather than POP3—I access emails all over the place), and a good webmail app would be really nice too. Finally, it has to just be a hosted email service, I don’t really need any webhosting as part of the package.

So, does anyone have any good recommendations?