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

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

Writing a poker server in Ruby: part 1

About a month ago I embarked on the project of writing a poker bot. It has all the things I enjoy about programming: it’s open-ended and can always be improved, it can be played against, and AI features heavily. There’s also a wealth of research on the topic: poker-ai.org and The University of Alberta Computer Poker Research Group are the two sites I use the most. I started by plugging in to Poker Academy, a game featuring strong AI opponents and a decent user interface....

July 14, 2013 · 5 min · Mike Cartmell