Skip to content

feat: refine implicit association syntax to declare traits without factory keyword#1796

Open
vburzynski wants to merge 2 commits intomainfrom
vrb-experiment-alternate-implicit-association-syntax
Open

feat: refine implicit association syntax to declare traits without factory keyword#1796
vburzynski wants to merge 2 commits intomainfrom
vrb-experiment-alternate-implicit-association-syntax

Conversation

@vburzynski
Copy link
Copy Markdown
Contributor

This refines the implicit association syntax to make it possible to declare traits without having to use the special factory keyword.

previously you would have to write:

factory :comment do
  user factory: [:user, :admin], name: "Joe Slick"
end

which can now be simplified as:

factory :comment do
  user :admin, name: "Joe Slick"
end

this mirrors how you would write this in the explicit syntax:

factory :comment do
  association :user, :admin, name: "Joe Slick"
end

I was inspired after looking at #1552 which, as of this writing, has been open since 2022.

This refines the implicit association syntax to make it possible to
declare traits without having to use the special factory keyword.

previously you would write:

factory :comment do
  user factory: [:user, :admin], name: "Joe Slick"
end

which can now be simplified as:

factory :comment do
  user :admin, name: "Joe Slick"
end

this mirrors how you would write this in the explicit syntax:

factory :comment do
  association :user, :admin, name: "Joe Slick"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant