Skip to content

Commit 8dd8713

Browse files
committed
Make InternalAffairs/ExampleDescription aware of xit and fit
1 parent 0ea19f0 commit 8dd8713

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

lib/rubocop/cop/internal_affairs/example_description.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ExampleDescription < Base
6969
# @!method offense_example(node)
7070
def_node_matcher :offense_example, <<~PATTERN
7171
(block
72-
(send _ {:it :specify} $...)
72+
(send _ {:it :specify :xit :fit} $...)
7373
_args
7474
`(send nil? %RESTRICT_ON_SEND ...)
7575
)

spec/rubocop/cop/internal_affairs/example_description_spec.rb

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe RuboCop::Cop::InternalAffairs::ExampleDescription, :config do
44
context 'with `expect_offense`' do
5-
it 'registers an offense when given an improper description' do
5+
it 'registers an offense when given an improper description in `it`' do
66
expect_offense(<<~RUBY)
77
it 'does not register an offense' do
88
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description does not match use of `expect_offense`.
@@ -17,6 +17,51 @@
1717
RUBY
1818
end
1919

20+
it 'registers an offense when given an improper description in `xit`' do
21+
expect_offense(<<~RUBY)
22+
xit 'does not register an offense' do
23+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description does not match use of `expect_offense`.
24+
expect_offense('code')
25+
end
26+
RUBY
27+
28+
expect_correction(<<~RUBY)
29+
xit 'registers an offense' do
30+
expect_offense('code')
31+
end
32+
RUBY
33+
end
34+
35+
it 'registers an offense when given an improper description in `specify`' do
36+
expect_offense(<<~RUBY)
37+
specify 'does not register an offense' do
38+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description does not match use of `expect_offense`.
39+
expect_offense('code')
40+
end
41+
RUBY
42+
43+
expect_correction(<<~RUBY)
44+
specify 'registers an offense' do
45+
expect_offense('code')
46+
end
47+
RUBY
48+
end
49+
50+
it 'registers an offense when given an improper description in `fit`' do
51+
expect_offense(<<~RUBY)
52+
fit 'does not register an offense' do
53+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Description does not match use of `expect_offense`.
54+
expect_offense('code')
55+
end
56+
RUBY
57+
58+
expect_correction(<<~RUBY)
59+
fit 'registers an offense' do
60+
expect_offense('code')
61+
end
62+
RUBY
63+
end
64+
2065
it 'registers an offense when given an improper description for `registers no offense`' do
2166
expect_offense(<<~RUBY)
2267
it 'registers no offense' do

0 commit comments

Comments
 (0)