35 lines
863 B
Ruby
35 lines
863 B
Ruby
# 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
|