Terminal junkies rejoice! Now you can use Cucumber to test your command line interfaces just like you do for your web apps. Aruba from Cucumber creator Aslak Hellesøy provides familiar step definitions for testing output, exit statuses, and file system commands. Here’s an example feature file for testing exit statuses:

Feature: exit statuses

  In order to specify expected exit statuses
  As a developer using Cucumber
  I want to use the "the exit status should be" step

  Scenario: exit status of 0
    When I run "ruby -h"
    Then the exit status should be 0

  Scenario: non-zero exit status
    When I run "ruby -e 'exit 56'"
    Then the exit status should be 56

Aruba provides the exit status step:

Then /^the exit status should be (\d+)$/ do |exit_status|
  @last_exit_status.should == exit_status.to_i
end

To use Aruba just install the gem

sudo gem install aruba

and then require it in your env.rb or any file under features/support

require 'aruba'

Check out the source on GitHub or the Cucumber homepage for more info.


Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.