General

Gems

Web Based

Haiti

Cucumber step definitions for command line testing

I write a lot of command line programs. I like to test them by invoking the binary, through Cucumber. To support this, I often wind up writing a small set of command line helpers for every one of these programs.

I finally decided that's stupid, and extracted the command line helpers out of Seeing Is Believing and into its own gem, which I named Haiti, after Aruba, a similar but much more comprehensive gem.

Example:

Set it up in features/support/env.rb, you need to tell it what directories to add to the path so that it can invoke your binaries (bin_dir), and what directory to write its files and evaluate inside of (proving_grounds_dir).

require 'haiti'

Haiti.configure do |config|
  config.proving_grounds_dir = File.expand_path '../../../proving_grounds', __FILE__
  config.bin_dir             = File.expand_path '../../../bin',             __FILE__
end

Then in a feature file

Feature:
  Scenario:
    Given the file "file2":
    """
    body{{1+1}}
    """
    When I run 'cat file2'
    Then stdout is "body2"

Code is on github.