Update test completion

This commit is contained in:
Shohei YOSHIDA 2023-09-29 11:23:43 +09:00
parent 1a9467fdff
commit 7a19598927
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 41 additions and 67 deletions

View File

@ -106,6 +106,27 @@ _rails() {
'(--db --database)'{--db=,--database=}'[Specify the database to use]:database:_files' \
&& ret=0
;;
(test|t|test:system)
_arguments \
'(- *)'{-h,--help}'[Show this help message and quit]' \
'--no-plugins[Bypass minitest plugin auto-loading]' \
'(-s --seed)'{-s,--seed=}'[Sets random seed]:seed' \
'(-v -verbose)'{-v,--verbose}'[Show progress processing files]' \
'--show-skips[Show skipped at the end of run]' \
\*{-n,--name=}'[Filter run on /regexp/ or string]:pattern' \
*--exclude='[Exclude /regexp/ or string from run]:pattern' \
\*{-S,--skip=}'[Skip reporting of certain types of results]' \
'(-w --warnings)'{-w,--warnings}'[Run with Ruby warnings enabled]' \
'(-e --environment)'{-e,--environment=}'[Run tests in the given environment]' \
'(-b --backtrace)'{-b,--backtrace}'[Show the complete backtrace]' \
'(-d --defer-output)'{-d,--defer-output}'[Output test failures and errors after the test run]' \
'(-f --fail-fast)'{-f,--fail-fast}'[Abort test run on first failure or error]' \
'(-c --color --no-color)'{-c,--color}'[Enable color in the output]' \
'(-c --color --no-color)--no-color[Disable color in the output]' \
'--profile=[Enable profiling of tests and list the slowest test cases]:count' \
'(-p --pride)'{-p,--pride}'[Show your testing pride]' \
&& ret=0
;;
esac
;;
esac
@ -129,11 +150,12 @@ _rails_subcommands() {
{generate,g}'[Generate new code]'
{console,c}'[Start the Rails console]'
{server,s}'[Start the Rails server]'
{test,t}'[Run tests]'
"test\\:system[Run systems test only]"
{dbconsole,db}'[Start a console for the database specified in config/database.yml]'
{destroy,d}'[Remove code generated by "bin/rails generates"]'
plugin'[Install a plugin]'
{runner,r}'[Run a piece of code in the application environment]'
{test,t}'[Run tests]'
)
fi
@ -320,6 +342,11 @@ _rails_generate() {
'--skip-manifest[Do not update the stimulus manifest]'
)
;|
(jbuilder|migration|resource|scaffold)
opts+=(
'*:field:_rails_migration_fields'
)
;|
esac
_arguments $opts && ret=0
@ -352,54 +379,6 @@ _rails_generate_generator() {
_values 'generators' $generators
}
__rails_setup_generators_options() {
local -a runtime_options
__rails_setup_runtime_options
generators_options=(
$runtime_options
--skip-namespace'[Skip namespace (affects only isolated applications)]'
--old-style-hash"[Force using old style hash (:foo => 'bar') on Ruby >= 1.9]"
)
}
__rails_setup_model_generators_options() {
local -a generators_options
__rails_setup_generators_options
model_generators_options=(
$generators_options
'(-o --orm)'{-o,--orm=}'[Orm to be invoked]:orm'
)
}
__rails_setup_resource_generators_options() {
local -a model_generators_options
__rails_setup_model_generators_options
resource_generators_options=(
$model_generators_options
--force-plural'[Forces the use of a plural ModelName]'
--resource-route'[Indicates when to generate resource route]: :__rails_boolean'
)
}
__rails_boolean() {
_values 'boolean' 'true' 'false'
}
__rails_migration_fields() {
if compset -P '*:*:'; then
_values 'index' 'index' 'uniq'
else
if compset -P '*:'; then
_values -s ':' 'type' 'string' 'text' 'integer' 'float' 'decimal' 'datetime' 'timestamp' 'time' 'date' 'binary' 'boolean' 'references'
else
_guard '[[:alnum:]_]#' 'field'
fi
fi
}
_rails_plugin() {
local context state line curcontext="$curcontext"
@ -463,24 +442,6 @@ _rails_r() {
_rails_runner
}
_rails_test() {
local context state line curcontext="$curcontext"
_arguments -C \
': :->path'
case "$state" in
path)
_alternative \
'files:filename:_files -g "*.rb"'
;;
esac
}
_rails_t() {
_rails_test
}
# Utilities
(( $+functions[_rails_is_in_app] )) ||
_rails_is_in_app() {
@ -502,6 +463,19 @@ _rails_path_or_url() {
'url:url:_urls'
}
(( $+functions[_rails_migration_fields] )) ||
_rails_migration_fields() {
if compset -P '*:*:'; then
_values 'index' 'index' 'uniq'
else
if compset -P '*:'; then
_values -s ':' 'type' 'string' 'text' 'integer' 'float' 'decimal' 'datetime' 'timestamp' 'time' 'date' 'binary' 'boolean' 'references'
else
_guard '[[:alnum:]_]#' 'field'
fi
fi
}
_rails "$@"
# Local Variables: