diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-03 18:11:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-03 18:11:31 +0300 |
commit | e6fa9529b4922a4c552e8908a2929ff995e8b53d (patch) | |
tree | 9ccfea4d253faa8c202f753631961a794af44ad6 /spec/rubocop/cop/graphql | |
parent | 720cf698151643831bf36e3bd4ccd1c8e9246184 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/graphql')
-rw-r--r-- | spec/rubocop/cop/graphql/enum_names_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/rubocop/cop/graphql/enum_names_spec.rb b/spec/rubocop/cop/graphql/enum_names_spec.rb new file mode 100644 index 00000000000..f45df068381 --- /dev/null +++ b/spec/rubocop/cop/graphql/enum_names_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'rubocop_spec_helper' +require_relative '../../../../rubocop/cop/graphql/enum_names' + +RSpec.describe RuboCop::Cop::Graphql::EnumNames do + describe 'class name' do + it 'adds an offense when class name does not end with `Enum`' do + expect_offense(<<~ENUM) + module Types + class Fake < BaseEnum + ^^^^ #{described_class::CLASS_NAME_SUFFIX_MSG} + graphql_name 'Fake' + end + end + ENUM + end + end + + describe 'graphql_name' do + it 'adds an offense when `graphql_name` is not set' do + expect_offense(<<~ENUM) + module Types + class FakeEnum < BaseEnum + ^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::GRAPHQL_NAME_MISSING_MSG} + end + end + ENUM + end + + it 'adds no offense when `declarative_enum` is used' do + expect_no_offenses(<<~ENUM) + module Types + class FakeEnum < BaseEnum + declarative_enum ::FakeModule::FakeDeclarativeEnum + end + end + ENUM + end + + it 'adds an offense when `graphql_name` includes `enum`' do + expect_offense(<<~ENUM) + module Types + class FakeEnum < BaseEnum + graphql_name 'FakeEnum' + ^^^^^^^^^^ #{described_class::GRAPHQL_NAME_WITH_ENUM_MSG} + end + end + ENUM + end + end +end |