diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 18:17:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 18:17:20 +0300 |
commit | 3670ddd229b178c0a2e09a1466ddfd7fd2f7855d (patch) | |
tree | 9be2a8155e0b14fb9a07b6a1c8bcfa629af4a25c /spec/rubocop | |
parent | 0b4adad74b76b34855e9a6d943f9b9188c3914fa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r-- | spec/rubocop/cop/rspec/avoid_conditional_statements_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/rubocop/cop/rspec/avoid_conditional_statements_spec.rb b/spec/rubocop/cop/rspec/avoid_conditional_statements_spec.rb new file mode 100644 index 00000000000..d2f5e4aa619 --- /dev/null +++ b/spec/rubocop/cop/rspec/avoid_conditional_statements_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'rubocop_spec_helper' + +require_relative '../../../../rubocop/cop/rspec/avoid_conditional_statements' + +RSpec.describe RuboCop::Cop::RSpec::AvoidConditionalStatements, feature_category: :tooling do + context 'when using conditionals' do + it 'flags if conditional' do + expect_offense(<<~RUBY) + if page.has_css?('[data-testid="begin-commit-button"]') + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't use `if` conditional statments in specs, it might create flakiness. See https://gitlab.com/gitlab-org/gitlab/-/issues/385304#note_1345437109 + find('[data-testid="begin-commit-button"]').click + end + RUBY + end + + it 'flags unless conditional' do + expect_offense(<<~RUBY) + RSpec.describe 'Multi-file editor new directory', :js, feature_category: :web_ide do + it 'creates directory in current directory' do + unless page.has_css?('[data-testid="begin-commit-button"]') + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't use `unless` conditional statments in specs, it might create flakiness. See https://gitlab.com/gitlab-org/gitlab/-/issues/385304#note_1345437109 + find('[data-testid="begin-commit-button"]').click + end + end + end + RUBY + end + + it 'flags ternary operator' do + expect_offense(<<~RUBY) + RSpec.describe 'Multi-file editor new directory', :js, feature_category: :web_ide do + it 'creates directory in current directory' do + user.present ? user : nil + ^^^^^^^^^^^^^^^^^^^^^^^^^ Don't use `(send (send nil :user) :present) ? (ternary)` conditional statments in specs, it might create flakiness. See https://gitlab.com/gitlab-org/gitlab/-/issues/385304#note_1345437109 + end + end + RUBY + end + end +end |