summaryrefslogtreecommitdiff
path: root/spec/rubocop/cop/graphql/descriptions_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/rubocop/cop/graphql/descriptions_spec.rb
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
downloadgitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/rubocop/cop/graphql/descriptions_spec.rb')
-rw-r--r--spec/rubocop/cop/graphql/descriptions_spec.rb45
1 files changed, 44 insertions, 1 deletions
diff --git a/spec/rubocop/cop/graphql/descriptions_spec.rb b/spec/rubocop/cop/graphql/descriptions_spec.rb
index 9ad40fad83d..af660aee165 100644
--- a/spec/rubocop/cop/graphql/descriptions_spec.rb
+++ b/spec/rubocop/cop/graphql/descriptions_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
require 'fast_spec_helper'
-require 'rubocop'
require_relative '../../../../rubocop/cop/graphql/descriptions'
RSpec.describe RuboCop::Cop::Graphql::Descriptions do
@@ -91,6 +90,50 @@ RSpec.describe RuboCop::Cop::Graphql::Descriptions do
end
end
+ context 'enum values' do
+ it 'adds an offense when there is no description' do
+ expect_offense(<<~TYPE)
+ module Types
+ class FakeEnum < BaseEnum
+ value 'FOO', value: 'foo'
+ ^^^^^^^^^^^^^^^^^^^^^^^^^ Please add a `description` property.
+ end
+ end
+ TYPE
+ end
+
+ it 'adds an offense when description does not end in a period' do
+ expect_offense(<<~TYPE)
+ module Types
+ class FakeEnum < BaseEnum
+ value 'FOO', value: 'foo', description: 'bar'
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `description` strings must end with a `.`.
+ end
+ end
+ TYPE
+ end
+
+ it 'does not add an offense when description is correct (defined using `description:`)' do
+ expect_no_offenses(<<~TYPE.strip)
+ module Types
+ class FakeEnum < BaseEnum
+ value 'FOO', value: 'foo', description: 'bar.'
+ end
+ end
+ TYPE
+ end
+
+ it 'does not add an offense when description is correct (defined as a second argument)' do
+ expect_no_offenses(<<~TYPE.strip)
+ module Types
+ class FakeEnum < BaseEnum
+ value 'FOO', 'bar.', value: 'foo'
+ end
+ end
+ TYPE
+ end
+ end
+
describe 'autocorrecting descriptions without periods' do
it 'can autocorrect' do
expect_offense(<<~TYPE)