debian-mirror-gitlab/spec/rubocop/cop/graphql/gid_expected_type_spec.rb

23 lines
710 B
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../../rubocop/cop/graphql/gid_expected_type'
2021-03-08 18:12:59 +05:30
RSpec.describe RuboCop::Cop::Graphql::GIDExpectedType do
2021-01-03 14:25:43 +05:30
subject(:cop) { described_class.new }
it 'adds an offense when there is no expected_type parameter' do
2021-03-11 19:13:27 +05:30
expect_offense(<<~TYPE)
2021-01-03 14:25:43 +05:30
GitlabSchema.object_from_id(received_id)
2021-03-11 19:13:27 +05:30
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Add an expected_type parameter to #object_from_id calls if possible.
2021-01-03 14:25:43 +05:30
TYPE
end
it 'does not add an offense for calls that have an expected_type parameter' do
expect_no_offenses(<<~TYPE.strip)
GitlabSchema.object_from_id("some_id", expected_type: SomeClass)
TYPE
end
end