Greenletters: Painless automation and testing for command-line applications


Did you ever use Expect to automate a complex command-line procedure, like an FTP upload? Expect is handy – and very powerful – but for Ruby projects it sure would be nice to be able to automate console apps directly from Ruby.

You may not have known it, but Ruby actually ships with a tiny Expect clone called expect.rb. Unfortunately it’s more of a proof of concept than a fully functional automation tool.

Enter Greenletters. Greenletters begins to bring some of the power of Expect to Ruby, with a simple, straightforward API. For example, here’s a scripted interaction with the classic Colossal Cave Adventure:

Greenletters also ships with some simple Cucumber steps, so you can immediately start using it to specify the behavior of your command-line apps:

Want to give it a try? Then:

And check out the examples/ directory for inspiration. Let me know what you think!