debian-mirror-gitlab/spec/rubocop/cop/api/base_spec.rb

30 lines
729 B
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'rubocop_spec_helper'
2021-01-03 14:25:43 +05:30
require_relative '../../../../rubocop/cop/api/base'
2021-03-08 18:12:59 +05:30
RSpec.describe RuboCop::Cop::API::Base do
2021-01-03 14:25:43 +05:30
let(:corrected) do
<<~CORRECTED
class SomeAPI < ::API::Base
end
CORRECTED
end
2021-03-11 19:13:27 +05:30
%w[Grape::API ::Grape::API Grape::API::Instance ::Grape::API::Instance].each do |offense|
2021-01-03 14:25:43 +05:30
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