Welcome to mirror list, hosted at ThFree Co, Russian Federation.

specs.rb « danger « tooling - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 68cab14165662b6b915fae602326c734474bf4fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

Dir[File.expand_path('specs/*_suggestion.rb', __dir__)].each { |file| require file }

module Tooling
  module Danger
    module Specs
      SPEC_FILES_REGEX = 'spec/'
      EE_PREFIX = 'ee/'

      SUGGESTIONS = [
        FeatureCategorySuggestion,
        MatchWithArraySuggestion,
        ProjectFactorySuggestion
      ].freeze

      def changed_specs_files(ee: :include)
        changed_files = helper.all_changed_files
        folder_prefix =
          case ee
          when :include
            "(#{EE_PREFIX})?"
          when :only
            EE_PREFIX
          when :exclude
            nil
          end

        changed_files.grep(%r{\A#{folder_prefix}#{SPEC_FILES_REGEX}})
      end

      def add_suggestions_for(filename)
        SUGGESTIONS.each do |suggestion|
          suggestion.new(filename, context: self).suggest
        end
      end
    end
  end
end