debian-mirror-gitlab/spec/rubocop/cop/avoid_becomes_spec.rb

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

30 lines
865 B
Ruby
Raw Permalink Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'rubocop_spec_helper'
2020-10-24 23:57:45 +05:30
require_relative '../../../rubocop/cop/avoid_becomes'
2021-03-08 18:12:59 +05:30
RSpec.describe RuboCop::Cop::AvoidBecomes do
2020-10-24 23:57:45 +05:30
it 'flags the use of becomes with a constant parameter' do
2021-03-11 19:13:27 +05:30
expect_offense(<<~CODE)
foo.becomes(Project)
^^^^^^^^^^^^^^^^^^^^ Avoid the use of becomes(SomeConstant), [...]
CODE
2020-10-24 23:57:45 +05:30
end
it 'flags the use of becomes with a namespaced constant parameter' do
2021-03-11 19:13:27 +05:30
expect_offense(<<~CODE)
foo.becomes(Namespace::Group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of becomes(SomeConstant), [...]
CODE
2020-10-24 23:57:45 +05:30
end
it 'flags the use of becomes with a dynamic parameter' do
2021-03-11 19:13:27 +05:30
expect_offense(<<~CODE)
model = Namespace
project = Project.first
project.becomes(model)
^^^^^^^^^^^^^^^^^^^^^^ Avoid the use of becomes(SomeConstant), [...]
CODE
2020-10-24 23:57:45 +05:30
end
end