Lapping it up with open arms

Joe Corcoran

Testing Bound jQuery Events

I’ve been using Jasmine, along with velesin’s jasmine-jquery, to test all of my JavaScript work recently. jasmine-jquery provides some really handy matchers, but one thing that’s missing is the ability to test whether an element has a bound event.

When Sammy Met Jasmine

Testing Sammy JavaScript apps with Pivotal Labs’ Jasmine BDD framework

Aaron Quint’s route-driven JavaScript framework Sammy, ships with QUnit tests. This is an obvious choice, since QUnit is jQuery’s test framework and Sammy depends on jQuery. I, however, am not the biggest fan of QUnit. It works really well, but I find the syntax a little unwieldy. On a recent project, I thought I’d try out Jasmine – a library-independent JavaScript BDD framework with a more readable syntax.

In this post I’ll run through some typical Sammy scenarios and show you how I’ve written the corresponding Jasmine tests. For reference, I’m using Jasmine 0.11.1 and Sammy 0.5.4.

Announcing Tweet Fighter

Firstly: allow me to bash the bible for a few lines. Over the past year or so I’ve become enamoured with Sinatra, the Ruby microframework. I’ve toyed with it, pushed it around, made it do things it didn’t want to do, locked it out in the cold and like a terminally happy pet, it still keeps coming back for more. Sinatra’s versatility is a product of its simplicity – it does its job well and the rest is up to you. Anyway, enough proselytising… on to Tweet Fighter.

Practical Uses for Sammy

I’ve recently been looking into a new Javascript framework named Sammy, written by the most excellent Aaron Quint. It was built on top of jQuery and intended to allow developers to build one-page applications, utilising the URL hash (the portion of the URL from the # symbol onwards) usually reserved for on-page anchors to give Javascript functions lovely descriptive routes.

I’m looking forward to writing applications in this way (and I’m trying to think of an excuse to do so), but what Sammy also kindly allows is direct, linkable access to the inner workings of some of the more usual Javascript implementations too.

I’ve put a few examples together to demonstrate.