This repository has been archived by the owner on Sep 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to choose rules applied, refs #4.
The DSL now accepts a tags array to define the set of tags available to choose whether or not to apply the rule. This is lifted straight from Cucumber tag expressions.
- Loading branch information
Andrew Crump
committed
Dec 12, 2011
1 parent
c735c3b
commit 3836620
Showing
9 changed files
with
101 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
#!/usr/bin/env ruby | ||
require 'foodcritic' | ||
require 'optparse' | ||
|
||
options = {} | ||
options[:tags] = [] | ||
parser = OptionParser.new do |opts| | ||
opts.banner = 'foodcritic [cookbook_path]' | ||
opts.on("-t", "--tags TAGS", "Only check against rules with the specified tags.") {|t|options[:tags] << t} | ||
end | ||
parser.parse! | ||
|
||
unless ARGV.length == 1 and Dir.exists?(ARGV[0]) | ||
STDERR.puts 'foodcritic [cookbook_path]' | ||
puts parser.help | ||
exit 1 | ||
end | ||
review = FoodCritic::Linter.new.check(ARGV[0]) | ||
puts review unless review.warnings.empty? | ||
|
||
review = FoodCritic::Linter.new.check(ARGV[0], options) | ||
puts review unless review.warnings.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Feature: Command line help | ||
|
||
In order to be able to learn about the options available for checking my cookbooks | ||
As a developer | ||
I want to be able to interactively get help on the options from the command line | ||
|
||
Scenario: No arguments | ||
Given I have installed the lint tool | ||
When I run it on the command line with no arguments | ||
Then the simple usage text should be displayed along with a non-zero exit code | ||
|
||
Scenario: Too many arguments | ||
Given I have installed the lint tool | ||
When I run it on the command line with too many arguments | ||
Then the simple usage text should be displayed along with a non-zero exit code | ||
|
||
Scenario: Non-existent cookbook directory | ||
Given I have installed the lint tool | ||
When I run it on the command line specifying a cookbook that does not exist | ||
Then the simple usage text should be displayed along with a non-zero exit code | ||
|
||
Scenario: Command help | ||
Given I have installed the lint tool | ||
When I run it on the command line with the help option | ||
Then the simple usage text should be displayed along with a zero exit code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Given /^I have installed the lint tool$/ do | ||
|
||
end | ||
|
||
When /^I run it on the command line with no arguments$/ do | ||
run_simple('foodcritic', false) | ||
end | ||
|
||
When /^I run it on the command line with too many arguments$/ do | ||
run_simple('foodcritic example example', false) | ||
end | ||
|
||
When /^I run it on the command line specifying a cookbook that does not exist$/ do | ||
run_simple('foodcritic no-such-cookbook', false) | ||
end | ||
|
||
When /^I run it on the command line with the help option$/ do | ||
run_simple('foodcritic --help', false) | ||
end | ||
|
||
Then /^the simple usage text should be displayed along with a (non-)?zero exit code$/ do |non_zero| | ||
assert_partial_output 'foodcritic [cookbook_path]', all_output | ||
assert_matching_output('( )+-t, --tags TAGS( )+Only check against rules with the specified tags.', all_output) | ||
if non_zero.nil? | ||
assert_exit_status 0 | ||
else | ||
assert_not_exit_status 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters