blob: 3e3e3abc27dc5b1abdbc0036f883bf46271c77dc (
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
30
31
32
33
34
|
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../rubocop/cop/avoid_becomes'
RSpec.describe RuboCop::Cop::AvoidBecomes, type: :rubocop do
include CopHelper
subject(:cop) { described_class.new }
it 'flags the use of becomes with a constant parameter' do
inspect_source('foo.becomes(Project)')
expect(cop.offenses.size).to eq(1)
end
it 'flags the use of becomes with a namespaced constant parameter' do
inspect_source('foo.becomes(Namespace::Group)')
expect(cop.offenses.size).to eq(1)
end
it 'flags the use of becomes with a dynamic parameter' do
inspect_source(<<~RUBY)
model = Namespace
project = Project.first
project.becomes(model)
RUBY
expect(cop.offenses.size).to eq(1)
end
end
|