diff options
author | Rémy Coutable <remy@rymai.me> | 2017-09-19 16:50:26 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-09-22 09:16:43 +0200 |
commit | 9025ce14d9c69443d8e412840c353b992048970b (patch) | |
tree | 6962736bcfb2a491bbd836d93bed67535dea1570 /spec/spec_helper.rb | |
parent | d103e95513704314a38ab8ae441851524031c4a1 (diff) | |
download | gitlab-ce-9025ce14d9c69443d8e412840c353b992048970b.tar.gz |
Automatically set a :type for specsrc/tag-specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 92735336572..dbf05b7f004 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -64,8 +64,16 @@ RSpec.configure do |config| config.infer_spec_type_from_file_location! - config.define_derived_metadata(file_path: %r{/spec/requests/(ci/)?api/}) do |metadata| - metadata[:api] = true + config.define_derived_metadata(file_path: %r{/spec/}) do |metadata| + location = metadata[:location] + + metadata[:api] = true if location =~ %r{/spec/requests/api/} + + # do not overwrite type if it's already set + next if metadata.key?(:type) + + match = location.match(%r{/spec/([^/]+)/}) + metadata[:type] = match[1].singularize.to_sym if match end config.raise_errors_for_deprecations! |