File tree 3 files changed +7
-5
lines changed
lib/rubocop/cop/rspec/factory_bot
spec/rubocop/cop/rspec/factory_bot
3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Master (Unreleased)
4
4
5
+ * ` FactoryBot/CreateList ` now ignores ` times ` blocks with an argument. ([ @Darhazer ] [ ] )
6
+
5
7
## 1.30.0 (2018-10-08)
6
8
7
9
* Add config to ` RSpec/VerifiedDoubles ` to enforcement of verification on unnamed doubles. ([ @BrentWheeldon ] [ ] )
Original file line number Diff line number Diff line change @@ -30,9 +30,10 @@ class CreateList < Cop
30
30
MSG_CREATE_LIST = 'Prefer create_list.' . freeze
31
31
MSG_N_TIMES = 'Prefer %<number>s.times.' . freeze
32
32
33
- def_node_matcher :n_times_block ? , <<-PATTERN
33
+ def_node_matcher :n_times_block_without_arg ? , <<-PATTERN
34
34
(block
35
35
(send (int _) :times)
36
+ (args)
36
37
...
37
38
)
38
39
PATTERN
@@ -47,7 +48,7 @@ class CreateList < Cop
47
48
48
49
def on_block ( node )
49
50
return unless style == :create_list
50
- return unless n_times_block ?( node )
51
+ return unless n_times_block_without_arg ?( node )
51
52
return unless contains_only_factory? ( node . body )
52
53
53
54
add_offense ( node . send_node ,
Original file line number Diff line number Diff line change 41
41
RUBY
42
42
end
43
43
44
- it 'flags n.times with argument' do
45
- expect_offense ( <<-RUBY )
44
+ it 'ignores n.times with argument' do
45
+ expect_no_offenses ( <<-RUBY )
46
46
3.times { |n| create :user, created_at: n.days.ago }
47
- ^^^^^^^ Prefer create_list.
48
47
RUBY
49
48
end
50
49
You can’t perform that action at this time.
0 commit comments