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

avoid_setup.rb « rspec « gitlab « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd2ed3b7e34d01921ba3728ee30f89e18b8cc125 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# frozen_string_literal: true

require 'rubocop-rspec'

module RuboCop
  module Cop
    module Gitlab
      module RSpec
        # This cop checks for use of constructs that may lead to deterioration in readability
        # in specs.
        #
        # @example
        #
        #   # bad
        #   before do
        #     enforce_terms
        #   end
        #
        #   it 'auto accepts terms and redirects to the group path' do
        #     visit sso_group_saml_providers_path(group, token: group.saml_discovery_token)
        #
        #     click_link 'Sign in'
        #
        #     expect(page).to have_content('Signed in with SAML')
        #   end
        #
        #   # good
        #   it 'auto accepts terms and redirects to the group path' do
        #     enforce_terms
        #
        #     visit sso_group_saml_providers_path(group, token: group.saml_discovery_token)
        #
        #     click_link 'Sign in'
        #
        #     expect(page).to have_content('Signed in with SAML')
        #   end
        #
        #   # good
        #   it 'registers the user and starts to import a project' do
        #     user_signs_up
        #
        #     expect_to_see_account_confirmation_page
        #
        #     confirm_account
        #
        #     user_signs_in
        #
        #     expect_to_see_welcome_form
        #
        #     fills_in_welcome_form
        #     click_on 'Continue'
        #
        #     expect_to_see_group_and_project_creation_form
        #
        #     click_on 'Import'
        #
        #     expect_to_see_import_form
        #
        #     fills_in_import_form
        #     click_on 'GitHub'
        #
        #     expect_to_be_in_import_process
        #   end
        #
        class AvoidSetup < RuboCop::Cop::Base
          MSG = 'Avoid the use of `%{name}` to keep this area as readable as possible. ' \
              'See https://gitlab.com/gitlab-org/gitlab/-/issues/373194'

          NOT_ALLOWED = %i[let_it_be let_it_be_with_refind let_it_be_with_reload let let!
                           before after around it_behaves_like shared_examples shared_examples_for
                           shared_context include_context subject].freeze

          RESTRICT_ON_SEND = NOT_ALLOWED

          def on_send(node)
            add_offense(node, message: format(MSG, name: node.children[1]))
          end
        end
      end
    end
  end
end