File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
spec/rubocop/cop/factory_bot Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,15 @@ def inspected_source_filename
205205 RUBY
206206 end
207207 end
208+ context 'when implicit association has factory and traits' do
209+ 'option' do
210+ it 'registers and corrects an offense' do
211+ expect_offense ( <<~RUBY )
212+ factory :article do
213+ author factory: %i[user admin]
214+ ^^^^^^^^^^^^^^^^^^^^^ Use explicit style to define associations.
215+ end
216+ RUBY
208217 context 'when implicit association has factory and traits' do
209218 'option' do
210219 it 'registers and corrects an offense' do
@@ -223,6 +232,14 @@ def inspected_source_filename
223232 end
224233 end
225234
235+ expect_correction ( <<~RUBY )
236+ factory :article do
237+ association :author, :admin, factory: :user
238+ end
239+ RUBY
240+ end
241+ end
242+
226243 context 'when default non implicit association method name is used' do
227244 it 'does not register an offense' do
228245 expect_no_offenses ( <<~RUBY )
You can’t perform that action at this time.
0 commit comments