summaryrefslogtreecommitdiff
path: root/spec/rubocop/cop/api/grape_api_instance_spec.rb
blob: 74f175cb70719fa514a84048f8758b0af5a9992b (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 'fast_spec_helper'
require 'rubocop'
require_relative '../../../../rubocop/cop/api/grape_api_instance'

RSpec.describe RuboCop::Cop::API::GrapeAPIInstance do
  include CopHelper

  subject(:cop) { described_class.new }

  it 'adds an offense when inheriting from Grape::API' do
    inspect_source(<<~CODE)
      class SomeAPI < Grape::API
      end
    CODE

    expect(cop.offenses.size).to eq(1)
  end

  it 'does not add an offense when inheriting from Grape::API::Instance' do
    inspect_source(<<~CODE)
      class SomeAPI < Grape::API::Instance
      end
    CODE

    expect(cop.offenses.size).to be_zero
  end
end