Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/rubocop/rspec/factory_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ module RuboCop
module RSpec
# RuboCop FactoryBot project namespace
module FactoryBot
ATTRIBUTE_DEFINING_METHODS = %i[factory trait transient ignore].freeze
ATTRIBUTE_DEFINING_METHODS = %i[
factory
ignore
trait
traits_for_enum
transient
].freeze
Comment on lines -7 to +13
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding :traits_for_enum caused a Layout/LineLength offense, so I turned the horizontal list into a vertical list. I also alphabetized the list to align with what was done with the other constants below.


UNPROXIED_METHODS = %i[
__send__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@
RUBY
end

it 'accepts valid traits_for_enum definition' do
expect_no_offenses(<<-RUBY)
FactoryBot.define do
factory :post do
traits_for_enum :status, [:draft, :published]
end
end
RUBY
end

bad = <<-RUBY
FactoryBot.define do
factory :post do
Expand Down