File tree Expand file tree Collapse file tree 5 files changed +50
-4
lines changed Expand file tree Collapse file tree 5 files changed +50
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Master (Unreleased)
4
4
5
+ - Add support for Unicode RIGHT SINGLE QUOTATION MARK in ` RSpec/ExampleWording ` . ([ @jdufresne ] )
6
+
5
7
## 3.0.2 (2024-07-02)
6
8
7
9
- Fix wrong autocorrect for ` RSpec/ScatteredSetup ` when hook contains heredoc. ([ @earlopain ] )
Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ class ExampleWording < Base
55
55
MSG_INSUFFICIENT_DESCRIPTION = 'Your example description is ' \
56
56
'insufficient.'
57
57
58
- SHOULD_PREFIX = /\A should(?:n't)?\b /i . freeze
59
- WILL_PREFIX = /\A (?:will|won't)\b /i . freeze
58
+ SHOULD_PREFIX = /\A should(?:n't|n’t )?\b /i . freeze
59
+ WILL_PREFIX = /\A (?:will|won't|won’t )\b /i . freeze
60
60
IT_PREFIX = /\A it /i . freeze
61
61
62
62
# @!method it_description(node)
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ module RuboCop
4
4
module RSpec
5
5
# RSpec example wording rewriter
6
6
class Wording
7
- SHOULDNT_PREFIX = /\A should(?:n't| not)\b /i . freeze
7
+ SHOULDNT_PREFIX = /\A should(?:n't|n’t| not)\b /i . freeze
8
8
SHOULDNT_BE_PREFIX = /#{ SHOULDNT_PREFIX } be\b /i . freeze
9
9
WILL_NOT_PREFIX = /\A will not\b /i . freeze
10
- WONT_PREFIX = /\A won't \b /i . freeze
10
+ WONT_PREFIX = /\A wo(?:n't|n’t) \b /i . freeze
11
11
ES_SUFFIX_PATTERN = /(?:o|s|x|ch|sh|z)\z /i . freeze
12
12
IES_SUFFIX_PATTERN = /[^aeou]y\z /i . freeze
13
13
Original file line number Diff line number Diff line change 148
148
RUBY
149
149
end
150
150
151
+ it 'finds description with `won’t` at the beginning' do
152
+ expect_offense ( <<~RUBY )
153
+ it "won’t do something" do
154
+ ^^^^^^^^^^^^^^^^^^ Do not use the future tense when describing your tests.
155
+ end
156
+ RUBY
157
+
158
+ expect_correction ( <<~RUBY )
159
+ it "does not do something" do
160
+ end
161
+ RUBY
162
+ end
163
+
151
164
it "finds description with `WON'T` at the beginning" do
152
165
expect_offense ( <<~RUBY )
153
166
it "WON'T do something" do
161
174
RUBY
162
175
end
163
176
177
+ it 'finds description with `WON’T` at the beginning' do
178
+ expect_offense ( <<~RUBY )
179
+ it "WON’T do something" do
180
+ ^^^^^^^^^^^^^^^^^^ Do not use the future tense when describing your tests.
181
+ end
182
+ RUBY
183
+
184
+ expect_correction ( <<~RUBY )
185
+ it "DOES NOT do something" do
186
+ end
187
+ RUBY
188
+ end
189
+
164
190
it 'flags a lone will' do
165
191
expect_offense ( <<~RUBY )
166
192
it 'will' do
200
226
RUBY
201
227
end
202
228
229
+ it 'flags a lone won’t' do
230
+ expect_offense ( <<~RUBY )
231
+ it "won’t" do
232
+ ^^^^^ Do not use the future tense when describing your tests.
233
+ end
234
+ RUBY
235
+
236
+ expect_correction ( <<~RUBY )
237
+ it "does not" do
238
+ end
239
+ RUBY
240
+ end
241
+
203
242
it 'finds leading its' do
204
243
expect_offense ( <<~RUBY )
205
244
it "it does something" do
Original file line number Diff line number Diff line change 24
24
'should wish me luck' => 'wishes me luck' ,
25
25
'should really only return one item' => 'really only returns one item' ,
26
26
"shouldn't return something" => 'does not return something' ,
27
+ 'shouldn’t return something' => 'does not return something' ,
27
28
'SHOULD RETAIN UPPERCASE' => 'RETAINS UPPERCASE' ,
28
29
"shouldn't be true" => 'is not true' ,
30
+ 'shouldn’t be true' => 'is not true' ,
29
31
"SHOULDN'T BE true" => 'IS NOT true' ,
32
+ 'SHOULDN’T BE true' => 'IS NOT true' ,
30
33
"SHOULDN'T NOT RETAIN UPPERCASE" => 'DOES NOT NOT RETAIN UPPERCASE' ,
34
+ 'SHOULDN’T NOT RETAIN UPPERCASE' => 'DOES NOT NOT RETAIN UPPERCASE' ,
31
35
'should WORRY' => 'WORRIES' ,
32
36
'should WISH me luck' => 'WISHES me luck' ,
33
37
'' => '' ,
34
38
'should' => '' ,
35
39
"shouldn't" => 'does not' ,
40
+ 'shouldn’t' => 'does not' ,
36
41
'should not' => 'does not' ,
37
42
'should fizz' => 'fizzes'
38
43
}
You can’t perform that action at this time.
0 commit comments