factory_bot: Update static attributes using dynamic (#772)

Co-authored-by: Rico Sta. Cruz <rstacruz@users.noreply.github.com>
This commit is contained in:
burhanudin hakim 2020-06-23 21:24:02 +07:00 committed by GitHub
parent 3a918a1619
commit 26e0f381fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,7 @@ title: Factory Bot
category: Ruby libraries
layout: 2017/sheet
weight: -3
updated: 2017-10-31
updated: 2020-06-24
keywords:
- "FactoryBot.define do"
- "factory :user"
@ -23,10 +23,10 @@ intro: |
```ruby
FactoryBot.define do
factory :user do
first_name 'John'
last_name 'Doe'
first_name { 'John' }
last_name { 'Doe' }
birthdate { 21.years.ago }
admin false
admin { false }
sequence(:username) { |n| "user#{n}" }
end
@ -124,7 +124,7 @@ end
```ruby
factory :user do
trait :admin do
admin true
admin { true }
end
end
```
@ -141,7 +141,7 @@ See: [Traits](http://www.rubydoc.info/gems/factory_bot/file/GETTING_STARTED.md#T
```ruby
factory :user do
first_name 'John'
first_name { 'John' }
factory :sample_user do
first_name { FFaker::Name.first_name }
@ -182,7 +182,7 @@ Works the same as nested factories.
```ruby
factory :user do
transient do
upcased true
upcased { true }
end
after :create do |user, options|