Testing CLI apps with Aruba (Ruby or Not)

CLI Acceptance Testing One of my hobbies is writing little CLI apps to create workflows, automate and solve issues I’m having. The one I’ve probably tinkered with the most is gitsweeper. Gitsweeper is a golang re-write of git-sweep, a python CLI tool I’d been using for a while to clean up branches that had been merged into the master branch. Because these apps are very small and self-contained, I want to be able to extensively test the happy and sad paths. For something like gitsweeper, there are a number of scenarios and edge cases to test against: A non-existent git repo, no branches being available, lack of permissions and so on. ...

April 9, 2024 · 9 min · Peter Souter

Drying up rspec with shared_examples

Day 17 in the #vDM30in30 Header image taken from https://www.relishapp.com/rspec/rspec-core/docs/example-groups/shared-examples One of the areas where it’s easy to have WET (We Enjoy Typing) code that you want to DRY (Don’t Repeat Yourself) up, is tests. When writing tests for similar areas of code, it’s easy to end up copy and pasting. You have to pieces of functionality that need to be tested in the same way, so why not copy and paste the testing code? ...

November 17, 2016 · 11 min · Peter Souter

Running Puppet acceptance tests in Docker in Travis

Day 4 in the #vDM30in30 One of the things that comes up a lot with Puppet code is testing, particularly acceptance testing. Just like with regular code, you want to make sure that changes to Puppet are not going to break the standard use-case for your module. Travis has been a boon for open-source testing. For a while, Travis was only for the syntax, linting and rspec tests. But in the last year they’ve added the ability to have Docker running in a Travis job. ...

November 4, 2016 · 13 min · Peter Souter

Testing Windows with Beaker without Cygwin

Edit: I’ve edited this post a few times since it was originally written in November, but now everything’s all dandy and working I thought I’d republish it as a new post! Testing Puppet on Windows So as someone who’s been doing way more work on Windows recently, I’ve become super interested in how to do systems acceptance testing on Windows. I ended up pairing with Liam at the Contributor Summit at Config Management Camp 2015 about this, as Liam’s behind a lot of the original work to get cygwin-less Beaker working for testing. Go read his blog posts over on the OpenTable, he knows way more about the background than I do! ...

June 9, 2016 · 13 min · Peter Souter

TDD/BDD with Puppet code using rspec-puppet

Header image: https://flic.kr/p/7Lx9Kk As someone who’s started out in dev and ended up falling into ops, a lot of my approaches are heavily influenced by what I cut my teeth on early on. Since I started out development Ruby and Rails, I learnt a lot about Test Driven Development. In fact, even before I did Rails, I was working a little on cuke4duke, a JVM Cucumber package. I’m a big fan of using TDD when writing Puppet code, as I think it really helps with my workflow and brings a lot of advantages. ...

February 18, 2015 · 10 min · Peter Souter