Skip to content

Commit 5950456

Browse files
committed
replace Available checks with dynamicaly generated list
1 parent a26c36b commit 5950456

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

test/minitest_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ def sh(command, options={})
7272
result
7373
end
7474

75+
def available_checks
76+
@available_checks ||=
77+
Dir["#{project_dir}/lib/plugins/pre_commit/checks/*.rb"].map{|path|
78+
path.gsub(/^.*\/([^\/]*)\.rb$/, "\\1")
79+
}.sort.join(" ")
80+
end
81+
7582
end; end
7683

7784
class MiniTest::Test

test/unit/pre-commit/cli_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
$stderr.string.must_equal('')
4747
$stdout.string.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
4848
Available providers: default(0) git(10) git_old(11) yaml(20) env(30)
49-
Available checks : before_all ci coffeelint common console_log csslint debugger gemfile_path go go_build go_fmt jshint jslint json local merge_conflict migration nb_space pry rails rspec_focus rubocop ruby ruby_symbol_hashrockets scss_lint tabs whitespace yaml
49+
Available checks : #{available_checks}
5050
Default checks : common rails
5151
Enabled checks : common rails
5252
Evaluated checks : tabs nb_space whitespace merge_conflict debugger pry local jshint console_log migration
@@ -77,7 +77,7 @@
7777
$stderr.string.must_equal('')
7878
$stdout.string.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
7979
Available providers: default(0) git(10) git_old(11) yaml(20) env(30)
80-
Available checks : before_all ci coffeelint common console_log csslint debugger gemfile_path go go_build go_fmt jshint jslint json local merge_conflict migration nb_space pry rails rspec_focus rubocop ruby ruby_symbol_hashrockets scss_lint tabs whitespace yaml
80+
Available checks : #{available_checks}
8181
Default checks : common rails
8282
Enabled checks : common rails
8383
Evaluated checks : tabs nb_space merge_conflict debugger pry local jshint console_log migration
@@ -99,7 +99,7 @@
9999
$stderr.string.must_equal('')
100100
$stdout.string.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
101101
Available providers: default(0) git(10) git_old(11) yaml(20) env(30)
102-
Available checks : before_all ci coffeelint common console_log csslint debugger gemfile_path go go_build go_fmt jshint jslint json local merge_conflict migration nb_space pry rails rspec_focus rubocop ruby ruby_symbol_hashrockets scss_lint tabs whitespace yaml
102+
Available checks : #{available_checks}
103103
Default checks : common rails
104104
Enabled checks : common rails
105105
Evaluated checks : tabs nb_space merge_conflict debugger pry local jshint console_log migration
@@ -121,7 +121,7 @@
121121
$stderr.string.must_equal('')
122122
$stdout.string.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
123123
Available providers: default(0) git(10) git_old(11) yaml(20) env(30)
124-
Available checks : before_all ci coffeelint common console_log csslint debugger gemfile_path go go_build go_fmt jshint jslint json local merge_conflict migration nb_space pry rails rspec_focus rubocop ruby ruby_symbol_hashrockets scss_lint tabs whitespace yaml
124+
Available checks : #{available_checks}
125125
Default checks : common rails
126126
Enabled checks : common rails
127127
Evaluated checks : tabs nb_space whitespace merge_conflict debugger pry local jshint console_log migration

test/unit/pre-commit/list_evaluator_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
it :list do
2323
subject.list.gsub(/\s+\n/,"\n").must_equal(<<-EXPECTED)
2424
Available providers: default(0)
25-
Available checks : before_all ci coffeelint common console_log csslint debugger gemfile_path go go_build go_fmt jshint jslint json local merge_conflict migration nb_space pry rails rspec_focus rubocop ruby ruby_symbol_hashrockets scss_lint tabs whitespace yaml
25+
Available checks : #{available_checks}
2626
Default checks :
2727
Enabled checks :
2828
Evaluated checks :

0 commit comments

Comments
 (0)