kle*_*ell 5 ruby-on-rails minitest rubocop
当我运行以下命令时,我希望RuboCop在测试运行之前检查我指定的应用程序目录:
bundle exec rake test
Run Code Online (Sandbox Code Playgroud)
我将以下任务添加到lib/tasks/test.rake:
require 'rubocop/rake_task'
# Add additional test suite definitions to the default test task here
namespace :test do
desc 'Runs RuboCop on specified directories'
RuboCop::RakeTask.new(:rubocop) do |task|
# Dirs: app, lib, test
task.patterns = ['app/**/*.rb', 'lib/**/*.rb', 'test/**/*.rb']
# Make it easier to disable cops.
task.options << "--display-cop-names"
# Abort on failures (fix your code first)
task.fail_on_error = false
end
end
Rake::Task[:test].enhance ['test:rubocop']
Run Code Online (Sandbox Code Playgroud)
结果:
$ bundle exec rake test
Running RuboCop...
Inspecting 9 files
.........
9 files inspected, no offenses detected
Run options: --seed 55148
# Running:
...................
Finished in 1.843280s, 10.3077 runs/s, 34.7207 assertions/s.
19 runs, 64 assertions, 0 failures, 0 errors, 0 skips
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
497 次 |
| 最近记录: |