Friday, January 21, 2011

List cucumber steps in a rails app

The following script prints all cucumber steps in a rails app.

#!/bin/sh

script_dir=`dirname $0`
app_dir=$script_dir/..
steps_dir=$app_dir/features/step_definitions
paths_file=$app_dir/features/support/paths.rb
steps_file=$app_dir/tmp/cucumber_steps.txt

if [ -e $steps_file ]; then rm $steps_file; fi

egrep -h ^Given ${steps_dir}/*_steps.rb | sort >> $steps_file
echo "" >> $steps_file
egrep -h ^When ${steps_dir}/*_steps.rb | sort >> $steps_file
echo "" >> $steps_file
egrep -h ^Then ${steps_dir}/*_steps.rb | sort >> $steps_file
echo "" >> $steps_file
egrep -h "[[:space:]]{4}when " $paths_file >> $steps_file

if [ -e $steps_file ]; then cat $steps_file; fi

No comments: