forked from rubocop/rubocop-rspec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
it_behaves_like_spec.rb
45 lines (36 loc) · 1.32 KB
/
it_behaves_like_spec.rb
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
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::RSpec::ItBehavesLike, :config do
let(:cop_config) do
{ 'EnforcedStyle' => enforced_style }
end
context 'when the enforced style is `it_behaves_like`' do
let(:enforced_style) { :it_behaves_like }
it 'flags a violation for it_should_behave_like' do
expect_offense(<<-RUBY)
it_should_behave_like 'a foo'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `it_behaves_like` over `it_should_behave_like` when including examples in a nested context.
RUBY
expect_correction(<<-RUBY)
it_behaves_like 'a foo'
RUBY
end
it 'does not flag a violation for it_behaves_like' do
expect_no_offenses("it_behaves_like 'a foo'")
end
end
context 'when the enforced style is `it_should_behave_like`' do
let(:enforced_style) { :it_should_behave_like }
it 'flags a violation for it_behaves_like' do
expect_offense(<<-RUBY)
it_behaves_like 'a foo'
^^^^^^^^^^^^^^^^^^^^^^^ Prefer `it_should_behave_like` over `it_behaves_like` when including examples in a nested context.
RUBY
expect_correction(<<-RUBY)
it_should_behave_like 'a foo'
RUBY
end
it 'does not flag a violation for it_behaves_like' do
expect_no_offenses("it_should_behave_like 'a foo'")
end
end
end