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

base_spec.rb « api « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 66e99b756433ac9b58fa4172d115ec6359ba72ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/api/base'

RSpec.describe RuboCop::Cop::API::Base do
  let(:corrected) do
    <<~CORRECTED
      class SomeAPI < ::API::Base
      end
    CORRECTED
  end

  %w[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