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>2021-08-09 12:22:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-09 12:22:41 +0300
commit65688a509249eb3be8ea4687d3fe6d1432a47392 (patch)
treedffc9c087dc2eda02e4656d5a0b16b5d7051e69f /spec/rubocop
parent4b8939db3d80469826a62f1409b921f96dac2498 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/graphql/descriptions_spec.rb98
1 files changed, 88 insertions, 10 deletions
diff --git a/spec/rubocop/cop/graphql/descriptions_spec.rb b/spec/rubocop/cop/graphql/descriptions_spec.rb
index f11b5346843..84520a89b08 100644
--- a/spec/rubocop/cop/graphql/descriptions_spec.rb
+++ b/spec/rubocop/cop/graphql/descriptions_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
field :a_thing,
- ^^^^^^^^^^^^^^^ Please add a `description` property.
+ ^^^^^^^^^^^^^^^ #{described_class::MSG_NO_DESCRIPTION}
GraphQL::Types::String,
null: false
end
@@ -25,10 +25,38 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
field :a_thing,
- ^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
+ ^^^^^^^^^^^^^^^ #{described_class::MSG_NO_PERIOD}
GraphQL::Types::String,
null: false,
- description: 'A descriptive description'
+ description: 'Description of a thing'
+ end
+ end
+ TYPE
+ end
+
+ it 'adds an offense when description begins with "A"' do
+ expect_offense(<<~TYPE)
+ module Types
+ class FakeType < BaseObject
+ field :a_thing,
+ ^^^^^^^^^^^^^^^ #{described_class::MSG_BAD_START}
+ GraphQL::Types::String,
+ null: false,
+ description: 'A description of the thing.'
+ end
+ end
+ TYPE
+ end
+
+ it 'adds an offense when description begins with "The"' do
+ expect_offense(<<~TYPE)
+ module Types
+ class FakeType < BaseObject
+ field :a_thing,
+ ^^^^^^^^^^^^^^^ #{described_class::MSG_BAD_START}
+ GraphQL::Types::String,
+ null: false,
+ description: 'The description of the thing.'
end
end
TYPE
@@ -41,7 +69,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
field :a_thing,
GraphQL::Types::String,
null: false,
- description: 'A descriptive description.'
+ description: 'Description of a thing.'
end
end
TYPE
@@ -64,7 +92,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
argument :a_thing,
- ^^^^^^^^^^^^^^^^^^ Please add a `description` property.
+ ^^^^^^^^^^^^^^^^^^ #{described_class::MSG_NO_DESCRIPTION}
GraphQL::Types::String,
null: false
end
@@ -77,7 +105,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
argument :a_thing,
- ^^^^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
+ ^^^^^^^^^^^^^^^^^^ #{described_class::MSG_NO_PERIOD}
GraphQL::Types::String,
null: false,
description: 'Behold! A description'
@@ -86,6 +114,34 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
TYPE
end
+ it 'adds an offense when description begins with "A"' do
+ expect_offense(<<~TYPE)
+ module Types
+ class FakeType < BaseObject
+ argument :a_thing,
+ ^^^^^^^^^^^^^^^^^^ #{described_class::MSG_BAD_START}
+ GraphQL::Types::String,
+ null: false,
+ description: 'A description.'
+ end
+ end
+ TYPE
+ end
+
+ it 'adds an offense when description begins with "The"' do
+ expect_offense(<<~TYPE)
+ module Types
+ class FakeType < BaseObject
+ argument :a_thing,
+ ^^^^^^^^^^^^^^^^^^ #{described_class::MSG_BAD_START}
+ GraphQL::Types::String,
+ null: false,
+ description: 'The description.'
+ end
+ end
+ TYPE
+ end
+
it 'does not add an offense when description is correct' do
expect_no_offenses(<<~TYPE.strip)
module Types
@@ -106,7 +162,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeEnum < BaseEnum
value 'FOO', value: 'foo'
- ^^^^^^^^^^^^^^^^^^^^^^^^^ Please add a `description` property.
+ ^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG_NO_DESCRIPTION}
end
end
TYPE
@@ -117,7 +173,29 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeEnum < BaseEnum
value 'FOO', value: 'foo', description: 'bar'
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG_NO_PERIOD}
+ end
+ end
+ TYPE
+ end
+
+ it 'adds an offense when description begins with "The"' do
+ expect_offense(<<~TYPE.strip)
+ module Types
+ class FakeEnum < BaseEnum
+ value 'FOO', value: 'foo', description: 'The description.'
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG_BAD_START}
+ end
+ end
+ TYPE
+ end
+
+ it 'adds an offense when description begins with "A"' do
+ expect_offense(<<~TYPE.strip)
+ module Types
+ class FakeEnum < BaseEnum
+ value 'FOO', value: 'foo', description: 'A description.'
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG_BAD_START}
end
end
TYPE
@@ -150,7 +228,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
field :a_thing,
- ^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
+ ^^^^^^^^^^^^^^^ #{described_class::MSG_NO_PERIOD}
GraphQL::Types::String,
null: false,
description: 'Behold! A description'
@@ -175,7 +253,7 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
module Types
class FakeType < BaseObject
field :a_thing,
- ^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
+ ^^^^^^^^^^^^^^^ #{described_class::MSG_NO_PERIOD}
GraphQL::Types::String,
null: false,
description: <<~DESC