From df83a61cb5c38cabd8b416ad4155582e6cf94746 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 30 Dec 2011 15:33:06 -0500 Subject: [PATCH] add help options --- features/bin/help.feature | 7 ++++ .../then/bin/i_should_get_help_output.rb | 4 ++ lib/jasmine/headless/options.rb | 42 ++++++++++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 features/bin/help.feature create mode 100644 features/steps/then/bin/i_should_get_help_output.rb diff --git a/features/bin/help.feature b/features/bin/help.feature new file mode 100644 index 0000000..cf3461d --- /dev/null +++ b/features/bin/help.feature @@ -0,0 +1,7 @@ +Feature: Bin - Help + Scenario: Display the Help + Given I have a test suite + When I run `bin/jasmine-headless-webkit -h` + Then I should get help output + And the exit status should be 0 + diff --git a/features/steps/then/bin/i_should_get_help_output.rb b/features/steps/then/bin/i_should_get_help_output.rb new file mode 100644 index 0000000..70a252c --- /dev/null +++ b/features/steps/then/bin/i_should_get_help_output.rb @@ -0,0 +1,4 @@ +Then /^I should get help output$/ do + @output.should include("Usage:") +end + diff --git a/lib/jasmine/headless/options.rb b/lib/jasmine/headless/options.rb index 4cdfe8a..8a51cf8 100644 --- a/lib/jasmine/headless/options.rb +++ b/lib/jasmine/headless/options.rb @@ -75,6 +75,10 @@ module Jasmine add_reporter(arg) when '--out' add_reporter_file(arg) + when '-h', '--help' + print_help + + exit end end @@ -100,7 +104,8 @@ module Jasmine [ '--list', '-l', GetoptLong::NO_ARGUMENT ], [ '--seed', GetoptLong::REQUIRED_ARGUMENT ], [ '--format', '-f', GetoptLong::REQUIRED_ARGUMENT ], - [ '--out', GetoptLong::REQUIRED_ARGUMENT ] + [ '--out', GetoptLong::REQUIRED_ARGUMENT ], + [ '-h', '--help', GetoptLong::NO_ARGUMENT ] ) command_line_args.each { |*args| process_option(*args) } @@ -146,6 +151,41 @@ module Jasmine def add_reporter_file(file) @options[:reporters].last << file end + + def print_help + options = [ + [ '-c, --colors', 'Enable colors (default: disabled)' ], + [ '-nc, --no-colors', 'Disable colors' ], + [ '--cache', 'Enable cache (default: enabled)' ], + [ '--no-cache', 'Disable cache' ], + [ '--keep', 'Keep runner files on failure' ], + [ '--runner-out ', 'Write runner to specified filename' ], + [ '-j, --jasmine-config ', 'Jasmine Yaml config to use' ], + [ '--no-full-run', 'Do not perform a full spec run after a successful targeted spec run' ], + [ '-l, --list', 'List files in the order they will be required' ], + [ '--seed', 'Random order seed for spec file ordering' ], + [ '-f, --format >', 'Specify an output reporter and possibly output filename' ], + [ '--out ', 'Specify output filename for last defined reporter' ], + [ '-h, --help', "You're looking at it" ] + ] + + longest_length = options.collect(&:first).collect(&:length).max + + puts <<-HELP +Usage: #{$0} [ options ] [ spec files ] + +Options: +#{options.collect { |option, description| " #{option.ljust(longest_length)} #{description}" }.join("\n")} + +Available reporters: + Console Write out spec results to the console in a progress format (default) + File Write spec results in jasmine-headless-webkit ReportFile format + Tap Write spec results in TAP format + +Add reporters to the jasmine.HeadlessReporter object to access them + (ex: jasmine.HeadlessReporter.Teamcity for the Teamcity reporter) +HELP + end end end end