diff --git a/factory_girl.md b/factory_girl.md
index e990ba32d..7b077f75a 100644
--- a/factory_girl.md
+++ b/factory_girl.md
@@ -4,33 +4,24 @@ category: Ruby libraries
layout: default-ad
---
-### Paths
-
- test/factories.rb
- spec/factories.rb
- test/factories/*.rb
- spec/factories/*.rb
-
-### Factories
+## Factories
FactoryGirl.define do
factory :user do
- first_name "John"
- last_name "Doe"
+ first_name 'John'
+ last_name 'Doe'
birthdate { 21.years.ago }
admin false
- profile # assuming there's a factory :profile
+ sequence(:username) { |n| "user#{n}" }
end
end
-### Others
+ # Also available:
+ factory :user, class: 'User'
+ factory :user, aliases: [:author]
- factory :user { ... }
- factory :sample_user, class: 'User' { ... }
- factory :user, aliases: [:author, :client] { ... }
-
-### Using
+## Using
FactoryGirl.build(:user)
@@ -39,7 +30,7 @@ layout: default-ad
attributes_for(:user) # hash
build_stubbed(:user) # stubbed out attributes
- build(:user, name: "John")
+ build(:user, name: 'John')
create_list(:user, 3)
build_list(:user, 3)
@@ -47,10 +38,13 @@ layout: default-ad
## Associations
factory :post do
+ association :author, factory: :user
+ association :author, factory: [:user, :admin]
+
author # assumes there's a factory :author
end
-### More complicated
+### After-create hooks
factory :post do
after :create do |post|
@@ -69,7 +63,21 @@ layout: default-ad
create :user, :admin
-## Transients
+## Nested factories
+
+ factory :user do
+ first_name 'John'
+
+ factory :sample_user do
+ first_name { FFaker::Name.first_name }
+ end
+ end
+
+ # create :sample_user
+
+ # Also: factory :sample_user, parent: :user
+
+## Options (transients)
factory :user do
transient do
@@ -83,22 +91,12 @@ layout: default-ad
create(user, upcased: true)
-### Etc
+## Paths
- # Sequences
- sequence(:username) { |n| "user#{n}" }
-
- # Associations
- association :author
- association :author, factory: user, last_name: "Ho"
- author
-
- after :create do |user, evaluator| ... end
- after :build
- end
-
- factory :user, aliases: [:author, :commenter] do ... end
- factory :admin_user, parent: :user do .. end
+ test/factories.rb
+ spec/factories.rb
+ test/factories/*.rb
+ spec/factories/*.rb
## See also
diff --git a/vainglory.md b/vainglory.md
index 9af5ba0fc..db9080c16 100644
--- a/vainglory.md
+++ b/vainglory.md
@@ -58,6 +58,7 @@ Last updated for Vainglory 1.22 with some 2.0 stuff.
| BP: [Breaking Point][BP] | 2600 | +55 wp | __Stacking dmg__
*stacking weapon dmg*, +35% atk speed |
| SM: [Serpent Mask][SM] | 2800 | +85 wp | __Lifesteal__
*stacking lifesteal*, +10% lifesteal |
| SB: [Sorrowblade][SB] | 3100 | +150 wp | __Raw power__
- |
+| PS: [Poison Shiv][PS] | ? | ? | __Mortal wounds__
- |
{:.wide}
[BS]: http://www.vaingloryfire.com/vainglory/wiki/items/bonesaw
@@ -67,6 +68,7 @@ Last updated for Vainglory 1.22 with some 2.0 stuff.
[TB]: http://www.vaingloryfire.com/vainglory/wiki/items/tension-bow
[TT]: http://www.vaingloryfire.com/vainglory/wiki/items/tornado-trigger
[TM]: http://www.vaingloryfire.com/vainglory/wiki/items/tyrants-monocle
+[PS]: http://www.vaingloryfire.com/vainglory/wiki/items/poison-shiv
## T3 Utils by HP