Parameterize the pattern for test locations

This commit allows users to specify search patterns when finding tests to
swaggerize. Omitting the pattern parameter makes rswag search with the default
patterns.

A typical usecase for this feature is when you already have a test suite set up
and you want to use rswag for generating swagger docs rather than high-coverage
testing.

Usage:

rake rswag:specs:swaggerize PATTERN='/your_path..'
This commit is contained in:
Karl Johansson
2019-11-15 14:34:07 +01:00
parent 02a5bc988f
commit 3cd9d38e19
2 changed files with 13 additions and 2 deletions

View File

@@ -5,7 +5,10 @@ namespace :rswag do
desc 'Generate Swagger JSON files from integration specs'
RSpec::Core::RakeTask.new('swaggerize') do |t|
t.pattern = 'spec/requests/**/*_spec.rb, spec/api/**/*_spec.rb, spec/integration/**/*_spec.rb'
t.pattern = ENV.fetch(
'PATTERN',
'spec/requests/**/*_spec.rb, spec/api/**/*_spec.rb, spec/integration/**/*_spec.rb'
)
# NOTE: rspec 2.x support
if Rswag::Specs::RSPEC_VERSION > 2 && Rswag::Specs.config.swagger_dry_run
@@ -18,4 +21,3 @@ namespace :rswag do
end
task :rswag => ['rswag:specs:swaggerize']