gitlab-org--gitlab-foss/spec/rubocop/cop/avoid_becomes_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
903 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../rubocop/cop/avoid_becomes'
RSpec.describe RuboCop::Cop::AvoidBecomes do
subject(:cop) { described_class.new }
it 'flags the use of becomes with a constant parameter' do
expect_offense(<<~CODE)
foo.becomes(Project)
^^^^^^^^^^^^^^^^^^^^ Avoid the use of becomes(SomeConstant), [...]
CODE
end
it 'flags the use of becomes with a namespaced constant parameter' do
expect_offense(<<~CODE)
foo.becomes(Namespace::Group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of becomes(SomeConstant), [...]
CODE
end
it 'flags the use of becomes with a dynamic parameter' do
expect_offense(<<~CODE)
model = Namespace
project = Project.first
project.becomes(model)
^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of becomes(SomeConstant), [...]
CODE
end
end