Skip to content

Commit

Permalink
Improve option documenting-step and fix bug.
Browse files Browse the repository at this point in the history
Seems I mis-understood what `\w` did in the regex and then never
documented an option with a less-than-three word.

This relaxes the requirement, but it seems a reasonable-enough compromise.

Closes #37
  • Loading branch information
davetron5000 committed Dec 8, 2012
1 parent c0e476d commit 3ab4088
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion features/bootstrap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ Feature: Bootstrap a new command-line app
When I get help for "methadone"
Then the exit status should be 0
And the following options should be documented:
|--force|
| --force | |
| --readme | which is negatable |
| -l, --license | which is not negatable |
| --log-level | |
And the banner should be present
And the banner should document that this app takes options
And the banner should document that this app's arguments are:
Expand Down
19 changes: 15 additions & 4 deletions lib/methadone/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ module Methadone
#
# When I get help for "command_to_run"
#
# * Make sure that each option shows up in the help and has *some* sort of documentation
# * Make sure that each option shows up in the help and has *some* sort of documentation. By default,
# the options won't be re2quired to be negatable.
#
# Then the following options should be documented:
# |--force|
# |-x |
#
# Then the following options should be documented:
# |--force| which is negatable |
# |-x | which is not negatable |
#
# * Check an individual option for documentation:
#
# Then the option "--force" should be documented
# Then the option "--force" should be documented which is negatable
#
# * Checks that the help has a proper usage banner
#
Expand Down Expand Up @@ -56,12 +62,17 @@ module Cucumber

Then /^the following options should be documented:$/ do |options|
options.raw.each do |option|
step %(the option "#{option[0]}" should be documented)
step %(the option "#{option[0]}" should be documented #{option[1]})
end
end

Then /^the option "([^"]*)" should be documented$/ do |option|
step %(the output should match /\\s*#{Regexp.escape(option)}[\\s\\W]+\\w\\w\\w+/)
Then /^the option "([^"]*)" should be documented(.*)$/ do |options,qualifiers|
options.split(',').map(&:strip).each do |option|
if qualifiers.strip == "which is negatable"
option = option.gsub(/^--/,"--[no-]")
end
step %(the output should match /\\s*#{Regexp.escape(option)}[\\s\\W]+\\w[\\s\\w][\\s\\w]+/)
end
end

Then /^the banner should be present$/ do
Expand Down

0 comments on commit 3ab4088

Please # to comment.