File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
lib/rubocop/cop/rspec/factory_bot
spec/rubocop/cop/rspec/factory_bot Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,7 @@ def children_of_factory_block(node)
141141 block = node . parent
142142 return [ ] unless block
143143 return [ ] unless block . block_type?
144+ return [ ] unless block . body
144145
145146 if block . body . begin_type?
146147 block . body . children
Original file line number Diff line number Diff line change @@ -12,6 +12,23 @@ def inspected_source_filename
1212 context 'when EnforcedStyle is :implicit' do
1313 let ( :enforced_style ) { :implicit }
1414
15+ context 'when factory block is empty' do
16+ it 'does not register an offense' do
17+ expect_no_offenses ( <<~RUBY )
18+ factory :user do
19+ end
20+ RUBY
21+ end
22+ end
23+
24+ context 'with when factory has no block' do
25+ it 'does not register an offense' do
26+ expect_no_offenses ( <<~RUBY )
27+ factory :user
28+ RUBY
29+ end
30+ end
31+
1532 context 'when implicit style is used' do
1633 it 'does not register an offense' do
1734 expect_no_offenses ( <<~RUBY )
You can’t perform that action at this time.
0 commit comments