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:
Diffstat (limited to 'spec/rubocop/cop/api/base_spec.rb')
-rw-r--r--spec/rubocop/cop/api/base_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/rubocop/cop/api/base_spec.rb b/spec/rubocop/cop/api/base_spec.rb
new file mode 100644
index 00000000000..893bcf49627
--- /dev/null
+++ b/spec/rubocop/cop/api/base_spec.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require 'rubocop'
+require 'rubocop/rspec/support'
+require_relative '../../../../rubocop/cop/api/base'
+
+RSpec.describe RuboCop::Cop::API::Base, type: :rubocop do
+ include CopHelper
+
+ subject(:cop) { described_class.new }
+
+ let(:corrected) do
+ <<~CORRECTED
+ class SomeAPI < ::API::Base
+ end
+ CORRECTED
+ end
+
+ ['Grape::API', '::Grape::API', 'Grape::API::Instance', '::Grape::API::Instance'].each do |offense|
+ it "adds an offense when inheriting from #{offense}" do
+ expect_offense(<<~CODE)
+ class SomeAPI < #{offense}
+ #{'^' * offense.length} #{described_class::MSG}
+ end
+ CODE
+
+ expect_correction(corrected)
+ end
+ end
+
+ it 'does not add an offense when inheriting from BaseAPI' do
+ expect_no_offenses(corrected)
+ end
+end