John Leach

Tag: testing

Documentation that tells a story

Created · Tech · 4 comments

When reading technical documentation I too often come across examples like this:

let's assume you have a client called foo and a server called bar

or command examples like:

mysqldump -h server1 | mysql -h server2

When I write documentation, I prefer to tell a story. What is the client called, Steven? Are we taking a mysqldump of a production server and writing it to a staging server?

Continue reading “Documentation that tells a story” →

Testing XML with rspec, xpath and libxml

Created · Ruby, Tech · 4 comments

I'm currently working with the virtualization API libvirt which uses XML to represent virtual machines and I'm generating this XML using Ruby.  I'm using rspec to test my code and wanted to test that my output was as I expected.  I started out with rspec-hpricot-matchers which worked fine until I started testing slightly more complex xml, which hpricot wasn't handling well.

So I wrote a have_xml matcher using the rspec dsl which uses the libxml library to do the testing.  It's so simple it's not really worthy of a gem, so here it is (licensed under public domain).  The text check is optional and, to be honest, doesn't belong here really.  It should be a separate matcher.

Continue reading “Testing XML with rspec, xpath and libxml” →