From 8737b6e2f44883b2fbc9d5ba66d7b903806b2e6c Mon Sep 17 00:00:00 2001 From: Stephen Wrathall Date: Mon, 28 Oct 2019 17:02:53 +0800 Subject: [PATCH] Skip tests tagged as document: false on doc gen When running the below command to re-generate API docs: RAILS_ENV=test rake docs:generate it will execute every single rspec test under 'spec/acceptance/**/*_spec.rb'. It *even* executes the tests that are explicitly marked as: document: false With this new rake task, only the rspec tests that contribute to the generation of API documentation will be executed: RAILS_ENV=test rake docs:generate:skip_undocumenting Aside: For our team, this reduced the amount of tests being executed during docs generation down from 195 to 37. --- lib/tasks/docs.rake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/tasks/docs.rake b/lib/tasks/docs.rake index 28d0a07c..eafee534 100644 --- a/lib/tasks/docs.rake +++ b/lib/tasks/docs.rake @@ -11,3 +11,9 @@ RSpec::Core::RakeTask.new('docs:generate:ordered') do |t| t.pattern = 'spec/acceptance/**/*_spec.rb' t.rspec_opts = ["--format RspecApiDocumentation::ApiFormatter", "--order defined"] end + +desc "Generate API request documentation from API specs, and skip tests that don't generate any docs" +RSpec::Core::RakeTask.new('docs:generate:skip_undocumenting') do |t| + t.pattern = 'spec/acceptance/**/*_spec.rb' + t.rspec_opts = ["--format RspecApiDocumentation::ApiFormatter", "--tag ~@document:false"] +end