Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FactoryBot/AssociationStyle breaks if column name is ruby's keyword #58

Closed
znz opened this issue Jul 5, 2023 · 1 comment · Fixed by #60
Closed

FactoryBot/AssociationStyle breaks if column name is ruby's keyword #58

znz opened this issue Jul 5, 2023 · 1 comment · Fixed by #60
Labels
bug Something isn't working

Comments

@znz
Copy link

znz commented Jul 5, 2023

I think that this behavior may be intentional because auto correction of this cop is unsafe.

root@8e2c142c74c8:/tmp# cat f.rb
FactoryBot.define do
  factory :alias do
  end

  factory :comment do
    association :alias
  end
end
root@8e2c142c74c8:/tmp# cp f.rb spec/factories.rb
root@8e2c142c74c8:/tmp# rubocop -r rubocop-factory_bot --only FactoryBot/AssociationStyle -A spec/factories.rb
Inspecting 1 file
F

Offenses:

spec/factories.rb:6:5: C: [Corrected] FactoryBot/AssociationStyle: Use implicit style to define associations.
    association :alias
    ^^^^^^^^^^^^^^^^^^
spec/factories.rb:9:1: F: Lint/Syntax: unexpected token $end
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

1 file inspected, 2 offenses detected, 1 offense corrected
root@8e2c142c74c8:/tmp# cat spec/factories.rb
FactoryBot.define do
  factory :alias do
  end

  factory :comment do
    alias
  end
end
@znz
Copy link
Author

znz commented Jul 5, 2023

After I changed EnforcedStyle, I met #54.

@ydah ydah added the bug Something isn't working label Jul 5, 2023
ydah added a commit that referenced this issue Jul 5, 2023
…ion` is called in trait block and column name is keyword

Fix: #58
@ydah ydah closed this as completed in #60 Aug 25, 2023
ydah added a commit that referenced this issue Sep 7, 2023
…ion` is called in trait block and column name is keyword

Fix: #58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants