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 22
33## Master (Unreleased)
44
5+ - Add support for Unicode RIGHT SINGLE QUOTATION MARK in ` RSpec/ExampleWording ` . ([ @jdufresne ] )
6+
57## 3.0.2 (2024-07-02)
68
79- 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
5555 MSG_INSUFFICIENT_DESCRIPTION = 'Your example description is ' \
5656 'insufficient.'
5757
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
6060 IT_PREFIX = /\A it /i . freeze
6161
6262 # @!method it_description(node)
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ module RuboCop
44 module RSpec
55 # RSpec example wording rewriter
66 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
88 SHOULDNT_BE_PREFIX = /#{ SHOULDNT_PREFIX } be\b /i . freeze
99 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
1111 ES_SUFFIX_PATTERN = /(?:o|s|x|ch|sh|z)\z /i . freeze
1212 IES_SUFFIX_PATTERN = /[^aeou]y\z /i . freeze
1313
Original file line number Diff line number Diff line change 148148 RUBY
149149 end
150150
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+
151164 it "finds description with `WON'T` at the beginning" do
152165 expect_offense ( <<~RUBY )
153166 it "WON'T do something" do
161174 RUBY
162175 end
163176
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+
164190 it 'flags a lone will' do
165191 expect_offense ( <<~RUBY )
166192 it 'will' do
200226 RUBY
201227 end
202228
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+
203242 it 'finds leading its' do
204243 expect_offense ( <<~RUBY )
205244 it "it does something" do
Original file line number Diff line number Diff line change 2424 'should wish me luck' => 'wishes me luck' ,
2525 'should really only return one item' => 'really only returns one item' ,
2626 "shouldn't return something" => 'does not return something' ,
27+ 'shouldn’t return something' => 'does not return something' ,
2728 'SHOULD RETAIN UPPERCASE' => 'RETAINS UPPERCASE' ,
2829 "shouldn't be true" => 'is not true' ,
30+ 'shouldn’t be true' => 'is not true' ,
2931 "SHOULDN'T BE true" => 'IS NOT true' ,
32+ 'SHOULDN’T BE true' => 'IS NOT true' ,
3033 "SHOULDN'T NOT RETAIN UPPERCASE" => 'DOES NOT NOT RETAIN UPPERCASE' ,
34+ 'SHOULDN’T NOT RETAIN UPPERCASE' => 'DOES NOT NOT RETAIN UPPERCASE' ,
3135 'should WORRY' => 'WORRIES' ,
3236 'should WISH me luck' => 'WISHES me luck' ,
3337 '' => '' ,
3438 'should' => '' ,
3539 "shouldn't" => 'does not' ,
40+ 'shouldn’t' => 'does not' ,
3641 'should not' => 'does not' ,
3742 'should fizz' => 'fizzes'
3843 }
You can’t perform that action at this time.
0 commit comments