Automated Rails testing with Capybara and PhantomJS

Capybara is one of those tools that sounds great but is often frustrating. The claims of ‘no setup’ and ‘intuitive API’ make it sound like automating your browser testing is going to be a simple task. Unfortunately, the nature of these full-stack tests mean they’re often very tricky to get working reliably, and this has always put me off before. Testing should save you time, not create extra work. This weekend, starting on a new test suite, I decided to go about really getting a solid Capybara setup, and get a complex test passing every time without anysleep hacks....

October 26, 2014 · 5 min · Mike Cartmell

Making a game with Phaser

Today I felt like making a game, so I learnt about Phaser and set myself the task/challenge of recreating a simple game from my childhood. Phaser is incredibly fun and easy to get started, I’d recommend giving it a go! The game I chose was Tanx. I started with the excellent Phaser tutorial and converted it to CoffeeScript. It’s perfectly fine to use CoffeeScript with Phaser, or I guess any other language that compiles to JavaScript....

April 20, 2014 · 4 min · Mike Cartmell

Variable scope in Ruby

One big difference between Perl and Ruby is that Ruby has no lexical variables. This confuses me when programming Ruby, because I’m used to thinking ifwill create a new scope. It doesn’t. Variables defined inside if will be available outside, because they belong to the method scope. For example, in Ruby you can do this: def foo if true x = 2 end puts x end foo This prints 2....

April 14, 2014 · 2 min · Mike Cartmell

The Heartbleed bug

On reading about the Heartbleed bug bug, my first thoughts were: This sounds quite simple, is it really easy to spot? Why wasn’t this noticed during review? The bug is in the Heartbeat Extension for TLS, as described in this draft. Interestingly, this document does actually highlight the importance of checking the payload length: If payload_length is either shorter than expected and thus indicates padding in a HeartbeatResponse or exceeds the actual message length in any message type, an error Alert message using illegal_parameter as its AlertDescription MUST be sent in response...

April 8, 2014 · 2 min · Mike Cartmell

10 Singlish phrases I would actually use in the UK

Possibly not everyone knows that English is an official language of Singapore (one of 4.) What’s more, there is an unofficial (and sometimes frowned upon) mini-language called Singlish, derived from bits of Hokkien, Teochew, Malay, English and Tamil. Most of these words exist either to express something that does not have an English equivalent, or to say something more succinctly. Either way, it does come in handy, and it’s fun to use language that would be unacceptable or confusing back home!...

March 17, 2014 · 3 min · Mike Cartmell