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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-05 03:07:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-05 03:07:09 +0300
commitf50a7f8d970c50026e52c0b5d1c444b365d3b795 (patch)
tree86071eb3685930272e2a8c48a24ac3380af0a10f /spec/rubocop/cop/graphql
parent6d10e8955122e96a92bb980c04f1d7b116ed527a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/graphql')
-rw-r--r--spec/rubocop/cop/graphql/descriptions_spec.rb58
1 files changed, 55 insertions, 3 deletions
diff --git a/spec/rubocop/cop/graphql/descriptions_spec.rb b/spec/rubocop/cop/graphql/descriptions_spec.rb
index 5e3f9539ff4..6aee4b544f6 100644
--- a/spec/rubocop/cop/graphql/descriptions_spec.rb
+++ b/spec/rubocop/cop/graphql/descriptions_spec.rb
@@ -16,6 +16,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description does not end in a period' do
@@ -44,6 +46,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description begins with "The"' do
@@ -58,6 +62,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description contains the demonstrative "this"' do
@@ -72,6 +78,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'does not add an offense when a word contains the substring "this"' do
@@ -123,6 +131,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description does not end in a period' do
@@ -151,6 +161,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description begins with "The"' do
@@ -165,6 +177,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description contains the demonstrative "this"' do
@@ -179,6 +193,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'does not add an offense when a word contains the substring "this"' do
@@ -218,6 +234,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description does not end in a period' do
@@ -240,6 +258,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description begins with "A"' do
@@ -251,6 +271,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'adds an offense when description contains the demonstrative "this"' do
@@ -262,6 +284,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
TYPE
+
+ expect_no_corrections
end
it 'does not add an offense when a word contains the substring "this"' do
@@ -295,8 +319,8 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
- describe 'autocorrecting descriptions without periods' do
- it 'can autocorrect' do
+ describe 'autocorrecting periods in descriptions' do
+ it 'autocorrects missing periods' do
expect_offense(<<~TYPE)
module Types
class FakeType < BaseObject
@@ -321,7 +345,20 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
TYPE
end
- it 'can autocorrect a heredoc' do
+ it 'does not autocorrect if periods exist' do
+ expect_no_offenses(<<~TYPE)
+ module Types
+ class FakeType < BaseObject
+ field :a_thing,
+ GraphQL::Types::String,
+ null: false,
+ description: 'Behold! A description.'
+ end
+ end
+ TYPE
+ end
+
+ it 'autocorrects a heredoc' do
expect_offense(<<~TYPE)
module Types
class FakeType < BaseObject
@@ -349,5 +386,20 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
TYPE
end
+
+ it 'does not autocorrect a heredoc if periods exist' do
+ expect_no_offenses(<<~TYPE)
+ module Types
+ class FakeType < BaseObject
+ field :a_thing,
+ GraphQL::Types::String,
+ null: false,
+ description: <<~DESC
+ Behold! A description.
+ DESC
+ end
+ end
+ TYPE
+ end
end
end