Skip to content

Commit afe426c

Browse files
committed
Remove ExampleWording specs for empty config
There is no longer by default a "when configuration is empty" situation to test. We always have the default configuration when testing. The existing tests ("should only fail" -> "onlies fail") did not add much value.
1 parent 4e7272b commit afe426c

File tree

1 file changed

+175
-193
lines changed

1 file changed

+175
-193
lines changed
Lines changed: 175 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -1,198 +1,180 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::ExampleWording, :config do
4-
context 'with configuration' do
5-
let(:cop_config) do
6-
{
7-
'IgnoredWords' => %w[only really]
8-
}
9-
end
10-
11-
it 'ignores non-example blocks' do
12-
expect_no_offenses('foo "should do something" do; end')
13-
end
14-
15-
it 'finds description with `should` at the beginning' do
16-
expect_offense(<<-RUBY)
17-
it 'should do something' do
18-
^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
19-
end
20-
RUBY
21-
22-
expect_correction(<<-RUBY)
23-
it 'does something' do
24-
end
25-
RUBY
26-
end
27-
28-
it 'finds interpolated description with `should` at the beginning' do
29-
expect_offense(<<-'RUBY')
30-
it "should do #{:stuff}" do
31-
^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
32-
end
33-
RUBY
34-
35-
expect_correction(<<-'RUBY')
36-
it "does #{:stuff}" do
37-
end
38-
RUBY
39-
end
40-
41-
it 'finds description with `Should` at the beginning' do
42-
expect_offense(<<-RUBY)
43-
it 'Should do something' do
44-
^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
45-
end
46-
RUBY
47-
48-
expect_correction(<<-RUBY)
49-
it 'does something' do
50-
end
51-
RUBY
52-
end
53-
54-
it 'finds description with `shouldn\'t` at the beginning' do
55-
expect_offense(<<-RUBY)
56-
it "shouldn't do something" do
57-
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
58-
end
59-
RUBY
60-
61-
expect_correction(<<-RUBY)
62-
it "does not do something" do
63-
end
64-
RUBY
65-
end
66-
67-
it 'finds description with `SHOULDN\'T` at the beginning' do
68-
expect_offense(<<-RUBY)
69-
it "SHOULDN'T do something" do
70-
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
71-
end
72-
RUBY
73-
74-
expect_correction(<<-RUBY)
75-
it "DOES NOT do something" do
76-
end
77-
RUBY
78-
end
79-
80-
it 'flags a lone should' do
81-
expect_offense(<<-RUBY)
82-
it 'should' do
83-
^^^^^^ Do not use should when describing your tests.
84-
end
85-
RUBY
86-
87-
expect_correction(<<-RUBY)
88-
it '' do
89-
end
90-
RUBY
91-
end
92-
93-
it 'flags a lone should not' do
94-
expect_offense(<<-RUBY)
95-
it 'should not' do
96-
^^^^^^^^^^ Do not use should when describing your tests.
97-
end
98-
RUBY
99-
100-
expect_correction(<<-RUBY)
101-
it 'does not' do
102-
end
103-
RUBY
104-
end
105-
106-
it 'finds leading its' do
107-
expect_offense(<<-RUBY)
108-
it "it does something" do
109-
^^^^^^^^^^^^^^^^^ Do not repeat 'it' when describing your tests.
110-
end
111-
RUBY
112-
113-
expect_correction(<<-RUBY)
114-
it "does something" do
115-
end
116-
RUBY
117-
end
118-
119-
it 'finds leading it in interpolated description' do
120-
expect_offense(<<-'RUBY')
121-
it "it does #{action}" do
122-
^^^^^^^^^^^^^^^^^ Do not repeat 'it' when describing your tests.
123-
end
124-
RUBY
125-
126-
expect_correction(<<-'RUBY')
127-
it "does #{action}" do
128-
end
129-
RUBY
130-
end
131-
132-
it "skips words beginning with 'it'" do
133-
expect_no_offenses(<<-RUBY)
134-
it 'itemizes items' do
135-
end
136-
RUBY
137-
end
138-
139-
it 'skips descriptions without `should` at the beginning' do
140-
expect_no_offenses(<<-RUBY)
141-
it 'finds no should here' do
142-
end
143-
RUBY
144-
end
145-
146-
it 'skips descriptions starting with words that begin with `should`' do
147-
expect_no_offenses(<<-RUBY)
148-
it 'shoulders the burden' do
149-
end
150-
RUBY
151-
end
152-
153-
it 'skips interpolated description without literal `should` at the start' do
154-
expect_no_offenses(<<-'RUBY')
155-
it "#{should} not be here" do
156-
end
157-
RUBY
158-
end
159-
160-
it 'flags \-separated multiline strings' do
161-
expect_offense(<<-RUBY)
162-
it 'should do something '\\
163-
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
164-
'and correctly fix' do
165-
end
166-
RUBY
167-
168-
expect_correction(<<-RUBY)
169-
it 'does something and correctly fix' do
170-
end
171-
RUBY
172-
end
173-
174-
it 'flags \-separated multiline interpolated strings' do
175-
expect_offense(<<-'RUBY')
176-
it "should do something "\
177-
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
178-
"with #{object}" do
179-
end
180-
RUBY
181-
182-
expect_correction(<<-'RUBY')
183-
it "does something with #{object}" do
184-
end
185-
RUBY
186-
end
187-
end
188-
189-
context 'when configuration is empty' do
190-
include_examples 'autocorrect',
191-
'it "should have trait" do end',
192-
'it "has trait" do end'
193-
194-
include_examples 'autocorrect',
195-
'it "should only fail" do end',
196-
'it "onlies fail" do end'
4+
it 'ignores non-example blocks' do
5+
expect_no_offenses('foo "should do something" do; end')
6+
end
7+
8+
it 'finds description with `should` at the beginning' do
9+
expect_offense(<<-RUBY)
10+
it 'should do something' do
11+
^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
12+
end
13+
RUBY
14+
15+
expect_correction(<<-RUBY)
16+
it 'does something' do
17+
end
18+
RUBY
19+
end
20+
21+
it 'finds interpolated description with `should` at the beginning' do
22+
expect_offense(<<-'RUBY')
23+
it "should do #{:stuff}" do
24+
^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
25+
end
26+
RUBY
27+
28+
expect_correction(<<-'RUBY')
29+
it "does #{:stuff}" do
30+
end
31+
RUBY
32+
end
33+
34+
it 'finds description with `Should` at the beginning' do
35+
expect_offense(<<-RUBY)
36+
it 'Should do something' do
37+
^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
38+
end
39+
RUBY
40+
41+
expect_correction(<<-RUBY)
42+
it 'does something' do
43+
end
44+
RUBY
45+
end
46+
47+
it 'finds description with `shouldn\'t` at the beginning' do
48+
expect_offense(<<-RUBY)
49+
it "shouldn't do something" do
50+
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
51+
end
52+
RUBY
53+
54+
expect_correction(<<-RUBY)
55+
it "does not do something" do
56+
end
57+
RUBY
58+
end
59+
60+
it 'finds description with `SHOULDN\'T` at the beginning' do
61+
expect_offense(<<-RUBY)
62+
it "SHOULDN'T do something" do
63+
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
64+
end
65+
RUBY
66+
67+
expect_correction(<<-RUBY)
68+
it "DOES NOT do something" do
69+
end
70+
RUBY
71+
end
72+
73+
it 'flags a lone should' do
74+
expect_offense(<<-RUBY)
75+
it 'should' do
76+
^^^^^^ Do not use should when describing your tests.
77+
end
78+
RUBY
79+
80+
expect_correction(<<-RUBY)
81+
it '' do
82+
end
83+
RUBY
84+
end
85+
86+
it 'flags a lone should not' do
87+
expect_offense(<<-RUBY)
88+
it 'should not' do
89+
^^^^^^^^^^ Do not use should when describing your tests.
90+
end
91+
RUBY
92+
93+
expect_correction(<<-RUBY)
94+
it 'does not' do
95+
end
96+
RUBY
97+
end
98+
99+
it 'finds leading its' do
100+
expect_offense(<<-RUBY)
101+
it "it does something" do
102+
^^^^^^^^^^^^^^^^^ Do not repeat 'it' when describing your tests.
103+
end
104+
RUBY
105+
106+
expect_correction(<<-RUBY)
107+
it "does something" do
108+
end
109+
RUBY
110+
end
111+
112+
it 'finds leading it in interpolated description' do
113+
expect_offense(<<-'RUBY')
114+
it "it does #{action}" do
115+
^^^^^^^^^^^^^^^^^ Do not repeat 'it' when describing your tests.
116+
end
117+
RUBY
118+
119+
expect_correction(<<-'RUBY')
120+
it "does #{action}" do
121+
end
122+
RUBY
123+
end
124+
125+
it "skips words beginning with 'it'" do
126+
expect_no_offenses(<<-RUBY)
127+
it 'itemizes items' do
128+
end
129+
RUBY
130+
end
131+
132+
it 'skips descriptions without `should` at the beginning' do
133+
expect_no_offenses(<<-RUBY)
134+
it 'finds no should here' do
135+
end
136+
RUBY
137+
end
138+
139+
it 'skips descriptions starting with words that begin with `should`' do
140+
expect_no_offenses(<<-RUBY)
141+
it 'shoulders the burden' do
142+
end
143+
RUBY
144+
end
145+
146+
it 'skips interpolated description without literal `should` at the start' do
147+
expect_no_offenses(<<-'RUBY')
148+
it "#{should} not be here" do
149+
end
150+
RUBY
151+
end
152+
153+
it 'flags \-separated multiline strings' do
154+
expect_offense(<<-RUBY)
155+
it 'should do something '\\
156+
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
157+
'and correctly fix' do
158+
end
159+
RUBY
160+
161+
expect_correction(<<-RUBY)
162+
it 'does something and correctly fix' do
163+
end
164+
RUBY
165+
end
166+
167+
it 'flags \-separated multiline interpolated strings' do
168+
expect_offense(<<-'RUBY')
169+
it "should do something "\
170+
^^^^^^^^^^^^^^^^^^^^^^ Do not use should when describing your tests.
171+
"with #{object}" do
172+
end
173+
RUBY
174+
175+
expect_correction(<<-'RUBY')
176+
it "does something with #{object}" do
177+
end
178+
RUBY
197179
end
198180
end

0 commit comments

Comments
 (0)