factory_bot 4.11.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/GETTING_STARTED.md +112 -36
  4. data/LICENSE +1 -1
  5. data/NEWS.md +340 -0
  6. data/README.md +19 -23
  7. data/lib/factory_bot.rb +97 -132
  8. data/lib/factory_bot/aliases.rb +1 -1
  9. data/lib/factory_bot/attribute.rb +4 -39
  10. data/lib/factory_bot/attribute_assigner.rb +21 -6
  11. data/lib/factory_bot/attribute_list.rb +2 -1
  12. data/lib/factory_bot/callback.rb +3 -2
  13. data/lib/factory_bot/configuration.rb +15 -19
  14. data/lib/factory_bot/declaration.rb +4 -4
  15. data/lib/factory_bot/declaration/association.rb +14 -1
  16. data/lib/factory_bot/declaration/dynamic.rb +3 -1
  17. data/lib/factory_bot/declaration/implicit.rb +7 -2
  18. data/lib/factory_bot/declaration_list.rb +1 -1
  19. data/lib/factory_bot/decorator.rb +5 -1
  20. data/lib/factory_bot/decorator/attribute_hash.rb +1 -1
  21. data/lib/factory_bot/decorator/invocation_tracker.rb +1 -1
  22. data/lib/factory_bot/definition.rb +7 -6
  23. data/lib/factory_bot/definition_proxy.rb +59 -62
  24. data/lib/factory_bot/errors.rb +7 -4
  25. data/lib/factory_bot/evaluation.rb +1 -1
  26. data/lib/factory_bot/evaluator.rb +5 -5
  27. data/lib/factory_bot/factory.rb +8 -8
  28. data/lib/factory_bot/factory_runner.rb +3 -3
  29. data/lib/factory_bot/find_definitions.rb +1 -1
  30. data/lib/factory_bot/internal.rb +102 -0
  31. data/lib/factory_bot/linter.rb +35 -18
  32. data/lib/factory_bot/null_factory.rb +3 -0
  33. data/lib/factory_bot/null_object.rb +2 -2
  34. data/lib/factory_bot/registry.rb +15 -6
  35. data/lib/factory_bot/reload.rb +3 -3
  36. data/lib/factory_bot/sequence.rb +0 -1
  37. data/lib/factory_bot/strategy/null.rb +2 -4
  38. data/lib/factory_bot/strategy/stub.rb +32 -31
  39. data/lib/factory_bot/strategy_calculator.rb +1 -1
  40. data/lib/factory_bot/strategy_syntax_method_registrar.rb +2 -2
  41. data/lib/factory_bot/syntax.rb +2 -2
  42. data/lib/factory_bot/syntax/default.rb +6 -6
  43. data/lib/factory_bot/syntax/methods.rb +32 -9
  44. data/lib/factory_bot/trait.rb +6 -3
  45. data/lib/factory_bot/version.rb +1 -1
  46. metadata +56 -30
  47. data/NEWS +0 -303
  48. data/lib/factory_bot/attribute/static.rb +0 -16
  49. data/lib/factory_bot/declaration/static.rb +0 -26
  50. data/lib/factory_bot/decorator/class_key_hash.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89e05780d4f57018d6825a36765bae4eafd20a5ea7ef0dd087f056a467d7c04a
4
- data.tar.gz: 57af145df0452c560e27c979f3f76a1ee680e6e0e7f10dbb6af253a02943f942
3
+ metadata.gz: 33780ea65377b4977bbc2ee3e16e126da53fbca4b820bd621537fa5b14bb8d85
4
+ data.tar.gz: f42bcc279ad3d3109ac513bcf73f07da96901fe00def25b8fbe4788ac96d1751
5
5
  SHA512:
6
- metadata.gz: 7bcda07de6b55b94f5ab976c058520adf4340cd6ca4518b06ceda03dc2a76ec190a0ef7519d3273440868b2f2f772f0b56f9c9aa71a990db6c32986b1a4f97c4
7
- data.tar.gz: 57506e51449c9b2516862498a3078e79c4426ff441e96ee46577b83dbafc97bb91b610b176d1d7b9167b722515954cafa2816c98b866ac8b8586cdbe73273e54
6
+ metadata.gz: f51989b517d39a8254751e63b49b4705b8f104cb7a0ff52f073fd65243e7199ea39e8bad88c37edb1b3397fb362027be843bd196586f01a29d98b4d2accad112
7
+ data.tar.gz: 2768474e23632487e2f8cec649a48d1721858c6cb7c4baf9ca79f3b5688d29e9fb448e42cca5cb6e20c046f90b458829055dae4e3d6ec5fc4a7983880ad5d8f5
@@ -0,0 +1,6 @@
1
+ lib/**/*.rb
2
+ -
3
+ GETTING_STARTED.md
4
+ CONTRIBUTING.md
5
+ NAME.md
6
+ LICENSE
@@ -4,16 +4,16 @@ Getting Started
4
4
  Update Your Gemfile
5
5
  -------------------
6
6
 
7
- If you're using Rails, you'll need to change the required version of `factory_bot_rails`:
7
+ If you're using Rails:
8
8
 
9
9
  ```ruby
10
- gem "factory_bot_rails", "~> 4.0"
10
+ gem "factory_bot_rails"
11
11
  ```
12
12
 
13
- If you're *not* using Rails, you'll just have to change the required version of `factory_bot`:
13
+ If you're *not* using Rails:
14
14
 
15
15
  ```ruby
16
- gem "factory_bot", "~> 4.0"
16
+ gem "factory_bot"
17
17
  ```
18
18
 
19
19
  JRuby users: factory_bot works with JRuby starting with 1.6.7.2 (latest stable, as per July 2012).
@@ -30,7 +30,7 @@ Configure your test suite
30
30
 
31
31
  ### RSpec
32
32
 
33
- If you're using Rails:
33
+ If you're using Rails, add the following configuration to `spec/support/factory_bot.rb` and be sure to require that file in `rails_helper.rb`:
34
34
 
35
35
  ```ruby
36
36
  RSpec.configure do |config|
@@ -102,7 +102,7 @@ If you do not include `FactoryBot::Syntax::Methods` in your test suite, then all
102
102
  Defining factories
103
103
  ------------------
104
104
 
105
- Each factory has a name and a set of attributes. The name is used to guess the class of the object by default, but it's possible to explicitly specify it:
105
+ Each factory has a name and a set of attributes. The name is used to guess the class of the object by default:
106
106
 
107
107
  ```ruby
108
108
  # This will guess the User class
@@ -112,16 +112,26 @@ FactoryBot.define do
112
112
  last_name { "Doe" }
113
113
  admin { false }
114
114
  end
115
-
116
- # This will use the User class (Admin would have been guessed)
117
- factory :admin, class: User do
118
- first_name { "Admin" }
119
- last_name { "User" }
120
- admin { true }
121
- end
122
115
  end
123
116
  ```
124
117
 
118
+ It is also possible to explicitly specify the class:
119
+
120
+ ```ruby
121
+ # This will use the User class (otherwise Admin would have been guessed)
122
+ factory :admin, class: User
123
+ ```
124
+
125
+ If the constant is not available
126
+ (if you are using a Rails engine that waits to load models, for example),
127
+ you can also pass a symbol or string,
128
+ which factory_bot will constantize later, once you start building objects:
129
+
130
+ ```ruby
131
+ # It's OK if Doorkeeper::AccessToken isn't loaded yet
132
+ factory :access_token, class: "Doorkeeper::AccessToken"
133
+ ```
134
+
125
135
  Because of the block syntax in Ruby, defining attributes as `Hash`es (for
126
136
  serialized/JSON columns, for example) requires two sets of curly brackets:
127
137
 
@@ -177,21 +187,15 @@ user.first_name
177
187
  # => "Joe"
178
188
  ```
179
189
 
190
+ Note that objects created with `build_stubbed` cannot be serialized with
191
+ `Marshal.dump`, since factory_bot defines singleton methods on these objects.
192
+
180
193
  Static Attributes
181
194
  ------------------
182
195
 
183
- Static attributes, without a block, are deprecated and will be removed in
184
- factory\_bot 5.
185
-
186
- ```ruby
187
- factory :user do
188
- # Do not use deprecated static attributes
189
- admin true
190
-
191
- # Use dynamic attribues instead
192
- admin { true }
193
- end
194
- ```
196
+ Static attributes (without a block) are no longer available in factory\_bot 5.
197
+ You can read more about the decision to remove them in
198
+ [this blog post](https://robots.thoughtbot.com/deprecating-static-attributes-in-factory_bot-4-11).
195
199
 
196
200
  Aliases
197
201
  -------
@@ -261,8 +265,8 @@ create(:user, upcased: true).name
261
265
  #=> "JOHN DOE - ROCKSTAR"
262
266
  ```
263
267
 
264
- Static and dynamic attributes can be created as transient attributes. Transient
265
- attributes will be ignored within attributes\_for and won't be set on the model,
268
+ Transient attributes will be ignored within attributes\_for and won't be
269
+ set on the model,
266
270
  even if the attribute exists or you attempt to override it.
267
271
 
268
272
  Within factory_bot's dynamic attributes, you can access transient attributes as
@@ -273,7 +277,7 @@ transient attributes from there.
273
277
  Method Name / Reserved Word Attributes
274
278
  -------------------------------
275
279
 
276
- If your attributes conflict with existing methods or reserved words you can define them with `add_attribute`.
280
+ If your attributes conflict with existing methods or reserved words (all methods in the [DefinitionProxy](https://github.com/thoughtbot/factory_bot/blob/master/lib/factory_bot/definition_proxy.rb) class) you can define them with `add_attribute`.
277
281
 
278
282
  ```ruby
279
283
  factory :dna do
@@ -343,9 +347,35 @@ factory :post do
343
347
  end
344
348
  ```
345
349
 
346
- The behavior of the association method varies depending on the build strategy used for the parent object.
350
+ In factory\_bot 5, associations default to using the same build strategy as
351
+ their parent object:
352
+
353
+ ```ruby
354
+ FactoryBot.define do
355
+ factory :author
356
+
357
+ factory :post do
358
+ author
359
+ end
360
+ end
361
+
362
+ post = build(:post)
363
+ post.new_record? # => true
364
+ post.author.new_record? # => true
365
+
366
+ post = create(:post)
367
+ post.new_record? # => false
368
+ post.author.new_record? # => false
369
+ ```
370
+
371
+ This is different than the default behavior for previous versions of
372
+ factory\_bot, where the association strategy would not always match the strategy
373
+ of the parent object. If you want to continue using the old behavior, you can
374
+ set the `use_parent_strategy` configuration option to `false`.
347
375
 
348
376
  ```ruby
377
+ FactoryBot.use_parent_strategy = false
378
+
349
379
  # Builds and saves a User and a Post
350
380
  post = create(:post)
351
381
  post.new_record? # => false
@@ -357,9 +387,11 @@ post.new_record? # => true
357
387
  post.author.new_record? # => false
358
388
  ```
359
389
 
360
- To not save the associated object, specify strategy: :build in the factory:
390
+ To not save the associated object, specify `strategy: :build` in the factory:
361
391
 
362
392
  ```ruby
393
+ FactoryBot.use_parent_strategy = false
394
+
363
395
  factory :post do
364
396
  # ...
365
397
  association :author, factory: :user, strategy: :build
@@ -476,6 +508,36 @@ create(:profile_with_languages).languages.length # 5
476
508
  create(:profile_with_languages, languages_count: 15).languages.length # 15
477
509
  ```
478
510
 
511
+ Polymorphic associations can be handled with traits:
512
+
513
+ ```ruby
514
+ FactoryBot.define do
515
+ factory :video
516
+ factory :photo
517
+
518
+ factory :comment do
519
+ for_photo # default to the :for_photo trait if none is specified
520
+
521
+ trait :for_video do
522
+ association :commentable, factory: :video
523
+ end
524
+
525
+ trait :for_photo do
526
+ association :commentable, factory: :photo
527
+ end
528
+ end
529
+ end
530
+ ```
531
+
532
+ This allows us to do:
533
+
534
+ ```ruby
535
+ create(:comment)
536
+ create(:comment, :for_video)
537
+ create(:comment, :for_photo)
538
+ ```
539
+
540
+
479
541
  Sequences
480
542
  ---------
481
543
 
@@ -515,6 +577,9 @@ factory :user do
515
577
  end
516
578
  ```
517
579
 
580
+ Note that defining sequences as implicit attributes will not work if you have a
581
+ factory with the same name as the sequence.
582
+
518
583
  And it's also possible to define an in-line sequence that is only used in
519
584
  a particular factory:
520
585
 
@@ -623,7 +688,7 @@ factory :story do
623
688
  end
624
689
  ```
625
690
 
626
- Traits can be used as attributes:
691
+ Traits can be used as implicit attributes:
627
692
 
628
693
  ```ruby
629
694
  factory :week_long_published_story_with_title, parent: :story do
@@ -633,6 +698,9 @@ factory :week_long_published_story_with_title, parent: :story do
633
698
  end
634
699
  ```
635
700
 
701
+ Note that defining traits as implicit attributes will not work if you have a
702
+ factory or sequence with the same name as the trait.
703
+
636
704
  Traits that define the same attributes won't raise AttributeDefinitionErrors;
637
705
  the trait that defines the attribute latest gets precedence.
638
706
 
@@ -893,7 +961,7 @@ If a gem were to give you a User factory:
893
961
  ```ruby
894
962
  FactoryBot.define do
895
963
  factory :user do
896
- full_name "John Doe"
964
+ full_name { "John Doe" }
897
965
  sequence(:username) { |n| "user#{n}" }
898
966
  password { "password" }
899
967
  end
@@ -998,9 +1066,11 @@ Example Rake task:
998
1066
  namespace :factory_bot do
999
1067
  desc "Verify that all FactoryBot factories are valid"
1000
1068
  task lint: :environment do
1001
- if Rails.env.test?
1002
- DatabaseCleaner.cleaning do
1069
+ if Rails.env.test?
1070
+ conn = ActiveRecord::Base.connection
1071
+ conn.transaction do
1003
1072
  FactoryBot.lint
1073
+ raise ActiveRecord::Rollback
1004
1074
  end
1005
1075
  else
1006
1076
  system("bundle exec rake factory_bot:lint RAILS_ENV='test'")
@@ -1012,8 +1082,7 @@ end
1012
1082
 
1013
1083
  After calling `FactoryBot.lint`, you'll likely want to clear out the
1014
1084
  database, as records will most likely be created. The provided example above
1015
- uses the database_cleaner gem to clear out the database; be sure to add the
1016
- gem to your Gemfile under the appropriate groups.
1085
+ uses an sql transaction and rollback to leave the database clean.
1017
1086
 
1018
1087
  You can lint factories selectively by passing only factories you want linted:
1019
1088
 
@@ -1047,6 +1116,13 @@ You can also specify the strategy used for linting:
1047
1116
  FactoryBot.lint strategy: :build
1048
1117
  ```
1049
1118
 
1119
+ Verbose linting will include full backtraces for each error, which can be
1120
+ helpful for debugging:
1121
+
1122
+ ```ruby
1123
+ FactoryBot.lint verbose: true
1124
+ ```
1125
+
1050
1126
  Custom Construction
1051
1127
  -------------------
1052
1128
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2017 Joe Ferris and thoughtbot, inc.
1
+ Copyright (c) 2008-2019 Joe Ferris and thoughtbot, inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/NEWS.md ADDED
@@ -0,0 +1,340 @@
1
+ # News
2
+
3
+ ## 5.1.0 (September 21, 2019)
4
+ * Added: "Did you mean?" style error message to help with typos in association declarations
5
+ * Changed: `NoMethodError` for static attributes now offers a "Did you mean?" style message
6
+ * Fixed: avoid undefining inherited evaluator methods
7
+ * Fixed: avoid stubbing id for records without a primary key
8
+ * Fixed: raise a helpful error for self-referencing traits to avoid a `SystemStackError`
9
+ * Deprecated: top-level methods meant only for internal use: `allow_class_lookup`, `allow_class_lookup`=, `register_trait`, `trait_by_name`, `traits`, `sequence_by_name`, `sequences`, `factory_by_name`, `register_factory`, `callback_names`, `register_callback`, `register_default_callbacks`, `register_default_strategies`, `strategies`
10
+
11
+ ## 5.0.2 (February 22, 2019)
12
+ * Bugfix: raise "Trait not registered" error when passing invalid trait arguments
13
+
14
+ ## 5.0.1 (February 15, 2019)
15
+ * Bugfix: Do not raise error when two sequences have the same name
16
+ in two traits that have the same name
17
+
18
+ ## 5.0.0 (February 1, 2019)
19
+ * Added: Verbose option to include full backtraces in the linting output
20
+ * Changed: use_parent_strategy now defaults to true, so by default the
21
+ build strategy will build, rather than create associations
22
+ * Changed: Passing a block when defining associations now raises an error
23
+ * Bugfix: use_parent_strategy is no longer reset by FactoryBot.reload
24
+ * Bugfix: rewind_sequences will now rewind local sequences along with the global ones
25
+ * Bugfix: the build_stubbed strategy now sets timestamps without changing the
26
+ the original behavior of the timestamp methods
27
+ * Bugfix: avoid a stack error when referring to an "attributes" attribute in initialize_with
28
+ * Removed: support for EOL versions of Ruby and Rails
29
+ * Removed: static attributes (use dynamic attributes with a block instead)
30
+ * Removed: looking up factories by class
31
+ * Removed: ignore method (use transient instead)
32
+ * Removed: duplicate_attribute_assignment_from_initialize_with configuration option
33
+ * Deprecated: allow_class_lookup configuration option
34
+
35
+ ## 4.11.1 (September 7, 2018)
36
+ * Documentation: Include .yardopts in the gem to fix broken RubyDoc links
37
+
38
+ ## 4.11.0 (August, 15, 2018)
39
+ * Bugfix: Do not raise error for valid build_stubbed methods: decrement, increment, and toggle
40
+ * Bugfix: Do not add timestamps with build_stubbed for objects that shouldn't have timestamps
41
+ * Deprecate static attributes
42
+
43
+ ## 4.10.0 (May 25, 2018)
44
+ * Allow sequences to be rewound
45
+
46
+ ## 4.9.0 (skipped - FactoryGirl only release)
47
+
48
+ ## 4.8.2 (October 20, 2017)
49
+ * Rename factory_girl to factory_bot
50
+
51
+ ## 4.8.1 (September 28, 2017)
52
+ * Explicitly define `#destroyed?` within the `Stub` strategy to return `nil` instead of raising
53
+ * Update various dependencies
54
+ * Update internal test suite to use RSpec's mocking/stubbing instead of mocha
55
+
56
+ ## 4.8.0 (December 16, 2016)
57
+ * Improve documentation
58
+ * Add `FactoryGirl.generate_list` to be consistent with `build_list`/`create_list` and friends
59
+ * Add `FactoryGirl.use_parent_strategy` configuration to allow associations to leverage parent build strategy
60
+
61
+ ## 4.7.0 (April 1, 2016)
62
+ * Improve documentation
63
+ * Improve instrumentation payload to include traits, overrides, and the factory itself
64
+ * Allow linting of traits
65
+ * Deprecate factory lookup by class name in preparation for 5.0
66
+ * Improve internal performance by using flat_map instead of map and compact
67
+ * Improve handling of dirty attributes after building a stubbed object
68
+ * Reduce warnings from redefining methods
69
+
70
+ ## 4.6.0 (skipped)
71
+
72
+ ## 4.5.0 (October 17, 2014)
73
+ * Improve FactoryGirl.lint by including exception and message in output
74
+ * Allow selective linting
75
+ * Use more explicit #public_send when doing attribute assignment
76
+ * Improve documentation around FactoryGirl.lint and initialize_with
77
+ * Deprecate #ignore in favor of #transient
78
+
79
+ ## 4.4.0 (February 10, 2014)
80
+ * Add FactoryGirl.lint
81
+ * Fix memory leak in duplicate traits
82
+ * Update documentation
83
+
84
+ ## 4.3.0 (November 3, 2013)
85
+ * Start testing against Rails 4.0 and Ruby 2.0.0
86
+ * Stop testing against Rails 3.0 and Ruby 1.9.2
87
+ * Add `*_pair` methods to only build two objects
88
+ * Raise if a method is defined with a FactoryGirl block (factory or trait)
89
+ * Allow use of Symbol#to_proc in callbacks
90
+ * Add global callbacks
91
+ * Improve GETTING_STARTED and README
92
+
93
+ ## 4.2.0 (January 18, 2013)
94
+ * Improve documentation
95
+ * Allow `*_list` syntax methods to accept a block
96
+ * Update gem dependencies
97
+ * Allow setting id for objects created with `build_stubbed`
98
+ * Fix Stub strategy to mimic ActiveRecord regarding `created_at`
99
+ * Evaluate sequences within the context of an Evaluator
100
+ * Fix Mocha deprecation warning
101
+ * Fix some warnings when running RUBYOPT=-w rake
102
+ * Convert test suite to RSpec's "expect" syntax
103
+
104
+ ## 4.1.0 (September 11, 2012)
105
+ * Allow multiple callbacks to bind to the same block
106
+ * Fix documentation surrounding the stub strategy
107
+
108
+ ## 4.0.0 (August 3, 2012)
109
+ * Remove deprecated cucumber_steps
110
+ * Remove deprecated alternate syntaxes
111
+ * Deprecate duplicate_attribute_assignment_from_initialize_with, which is now unused
112
+ as attributes assigned within initialize_with are not subsequently assigned
113
+
114
+ ## 3.6.1 (August 2, 2012)
115
+ Update README to include info about running with JRuby
116
+ * Update dependencies on RSpec and tiny versions of Rails in Appraisal
117
+ * Improve flexibility of using traits with associations and add documentation
118
+ * Stub update_column to raise to mirror ActiveRecord's change from update_attribute
119
+
120
+ ## 3.6.0 (July 27, 2012)
121
+ * Code/spec cleanup
122
+ * Allow factories with traits to be used in associations
123
+ * Refactor Factory to use DefinitionHierarchy to handle managing callbacks,
124
+ custom constructor, and custom to_create
125
+ * Add memoization to speed up factories providing attribute overrides
126
+ * Add initial support of JRuby when running in 1.9 mode
127
+ * Improve docs on what happens when including FactoryGirl::Syntax::Methods
128
+
129
+ ## 3.5.0 (June 22, 2012)
130
+ * Allow created_at to be set when using build_stubbed
131
+ * Deprecate FactoryGirl step definitions
132
+
133
+ ## 3.4.2 (June 19, 2012)
134
+ * Fix bug in traits with callbacks called implicitly in factories whose
135
+ callbacks trigger multiple times
136
+
137
+ ## 3.4.1 (June 18, 2012)
138
+ * Fix traits so they can be nested and referred to from other traits
139
+
140
+ ## 3.4.0 (June 11, 2012)
141
+ * Sequences support Enumerators
142
+ * Optionally disable duplicate assignment of attributes in initialize_with
143
+ * Make hash of public attributes available in initialize_with
144
+ * Support referring to a factory based on class name
145
+
146
+ ## 3.3.0 (May 13, 2012)
147
+ * Allow to_create, skip_create, and initialize_with to be defined globally
148
+ * Allow to_create, skip_create, and initialize_with to be defined within traits
149
+ * Fix deprecation messages for alternate syntaxes (make, generate, etc.)
150
+ * Improve library documentation
151
+ * Deprecate after_build, after_create, before_create, after_stub in favor of new callbacks
152
+ * Introduce new callback syntax: after(:build) {}, after(:custom) {}, or callback(:different) {}
153
+ This allows for declaring any callback, usable with custom strategies
154
+ * Add attributes_for_list and build_stubbed_list with the StrategySyntaxMethodRegistrar
155
+ * Allow use of syntax methods (build, create, generate, etc) implicitly in callbacks
156
+ * Internal refactoring of a handful of components
157
+
158
+ ## 3.2.0 (April 24, 2012)
159
+ * Use AS::Notifications for pub/sub to track running factories
160
+ * Call new within initialize_with implicitly on the build class
161
+ * Skip to_create with skip_create
162
+ * Allow registration of custom strategies
163
+ * Deprecate alternate syntaxes
164
+ * Implicitly call factory_bot's syntax methods from dynamic attributes
165
+
166
+ ## 3.1.0 (April 6, 2012)
167
+ * Sequences support aliases, which reference the same block
168
+ * Update documentation
169
+ * Add before_create callback
170
+ * Support use of #attribute_names method to determine available attributes for steps
171
+ * Use ActiveSupport::Deprecation for all deprecations
172
+
173
+ ## 3.0.0 (March 23, 2012)
174
+ * Deprecate the vintage syntax
175
+ * Remove Rails 2.x support
176
+ * Remove Ruby 1.8 support
177
+ * Remove deprecated features, including default_strategy, factory_name,
178
+ :method for defining default strategy, ignore on individual attributes, and
179
+ interacting with Factory the way you would FactoryGirl
180
+
181
+ ## 2.6.4 (March 16, 2012)
182
+ * Do not ignore names of transient attributes
183
+ * Ensure attributes set on instance are calculated uniquely
184
+
185
+ ## 2.6.3 (March 9, 2012)
186
+ * Fix issue with traits not being present the first time a factory is accessed
187
+ * Update available Cucumber step definitions to not require a trailing colon
188
+ when building a table of attributes to instantiate records with
189
+
190
+ ## 2.6.2 (March 9, 2012)
191
+ * Allow factories to use all their ancestors' traits
192
+ * Ignore bin dir generated by bundler
193
+ * Namespace ::Factory as top-level to fix vintage syntax issue with
194
+ Ruby 1.9.2-p3p18
195
+
196
+ ## 2.6.1 (March 2, 2012)
197
+ * Use FactoryGirl.reload in specs
198
+ * Clean up running named factories with a particular strategy with
199
+ FactoryGirl::FactoryRunner
200
+
201
+ ## 2.6.0 (February 17, 2012)
202
+ * Improve documentation of has_many associations in the GETTING_STARTED
203
+ document
204
+ * Deprecate :method in favor of :strategy when overriding an association's
205
+ build strategy
206
+
207
+ ## 2.5.2 (February 10, 2012)
208
+ * Fix step definitions to use associations defined in parent factories
209
+ * Add inline trait support to (build|create)_list
210
+ * Update ActiveSupport dependency to >= 2.3.9, which introduced
211
+ class_attribute
212
+
213
+ ## 2.5.1 (February 3, 2012)
214
+ * Fix attribute evaluation when the attribute isn't defined in the factory but
215
+ is a private method on Object
216
+ * Update rubygems on Travis before running tests
217
+ * Fix spec name
218
+ * Update GETTING_STARTED with correct usage of build_stubbed
219
+ * Update README with more info on initialize_with
220
+ * Honor :parent on factory over block nesting
221
+
222
+ ## 2.5.0 (January 20, 2012)
223
+ * Revert 'Deprecate build_stubbed and attributes_for'
224
+ * Implement initialize_with to allow overriding object instantiation
225
+ * Ensure FG runs against Rails 3.2.0
226
+
227
+ ## 2.4.2 (January 18, 2012)
228
+ * Fix inline traits' interaction with defaults on the factory
229
+
230
+ ## 2.4.1 (January 17, 2012)
231
+ * Deprecate build_stubbed and attributes_for
232
+ * Fix inline traits
233
+
234
+ ## 2.4.0 (January 13, 2012)
235
+ * Refactor internals of FactoryGirl to use anonymous class on which attributes
236
+ get defined
237
+ * Explicitly require Ruby 1.8.7 or higher in gemspec
238
+ * Fix documentation
239
+ * Add Gemnasium status to documentation
240
+ * Supplying a Class to a factory that overrides to_s no longer results in
241
+ getting the wrong Class constructed
242
+ * Be more agnostic about ORMs when using columns in FactoryGirl step
243
+ definitions
244
+ * Test against Active Record 3.2.0.rc2
245
+ * Update GETTING_STARTED to use Ruby syntax highlighting
246
+
247
+ ## 2.3.2 (November 26, 2011)
248
+ * Move logic of where instance.save! is set to Definition
249
+ * Fix method name from aliases_for? to alias_for?
250
+ * Refactor internal attribute handling to use an anonymous class instead of
251
+ faking Ruby's variable resolution. This allows for more sane usage of
252
+ attributes without having to manage sorting priority because attributes
253
+ can turn themselves into procs, which are used with define_method on a
254
+ class so attributes work correctly all the time.
255
+
256
+ ## 2.3.1 (November 23, 2011)
257
+ * Remove internally-used associate method from all the FactoryGirl::Proxy subclasses
258
+ * Move around requiring of files
259
+ * Consolidate errors into factory_bot.rb
260
+ * Refactor AttributeList to deal with priority only when iterating over
261
+ attributes
262
+ * Refactor internals of some of the Proxy subclasses
263
+ * Ensure callbacks on traits are executed in the correct order
264
+
265
+ ## 2.3.0 (November 18, 2011)
266
+ * Registries are named, resulting in better messages when factories, traits,
267
+ or sequences cannot be found
268
+ * Fix incorrect tests
269
+ * Internals refactoring introducing FactoryGirl::NullFactory,
270
+ FactoryGirl::Definition, and FactoryGirl::DeclarationList
271
+ * Use ActiveSupport for Hash#except and its delegation capabilities
272
+ * Fix usage of callbacks when added via implicit traits
273
+ * Use Bundler tasks and clean up dependencies
274
+ * Fix failing spec for big letters in factory name passed as symbol
275
+ * Add ability for traits to be added dynamically when creating an instance via
276
+ build, create, build_stubbed, or attributes_for
277
+
278
+ ## 2.2.0 (October 14, 2011)
279
+ * Clean up RSpec suite to not use 'should'
280
+ * Use create_list in step definitions
281
+ * Syntax methods that deal with ORM interaction (attributes_for, build, build_stubbed,
282
+ and create) now accept a block that yields the result. This results in a
283
+ more convenient way to interact with the result than using Object.tap.
284
+ * Standardize deprecation warnings
285
+ * Update transient attribute syntax to use blocks instead of calling ignore on
286
+ each attribute declaration
287
+ * Parents can be defined after children because factories are evaluated when
288
+ they're used; this means breaking up factories across multiple files will
289
+ behave as expected
290
+ * Large internal refactoring, including changing access modifiers for a
291
+ handful of methods for a more clearly defined API
292
+
293
+ ## 2.1.2 (September 23, 2011)
294
+ * Bugfix: Vintage syntax fixed after bug introduced in 2.1.1
295
+ * Introduce dependency on activesupport to remove code from Factory class
296
+
297
+ ## 2.1.1 (September 23, 2011) (yanked)
298
+ * Bugfix: Parent object callbacks are run before child object callbacks
299
+ * Declarations: allow overriding/modification of individual traits in child factories
300
+ * Callbacks refactored to not be attributes
301
+ * Updating documentation for formatting and clarity (incl. new specificity for cucumber)
302
+
303
+ ## 2.1.0 (September 02, 2011)
304
+ * Bugfix: created_at now defined for stubbed models
305
+ * Gemspec updated for use with Rails 3.1
306
+ * Factories can now be modified post-definition (useful for overriding defaults from gems/plugins)
307
+ * All factories can now be reloaded with Factory.reload
308
+ * Add :method => build to factory associations to prevent saving of associated objects
309
+ * Factories defined in {Rails.root}/factories are now loaded by default
310
+ * Various documentation updates
311
+
312
+ ## 1.1.4 (November 28, 2008)
313
+ * Factory.build now uses Factory.create for associations of the built object
314
+ * Factory definitions are now detected in subdirectories, such as
315
+ factories/person_factory.rb (thanks to Josh Nichols)
316
+ * Factory definitions are now loaded after the environment in a Rails project
317
+ (fixes some issues with dependencies being loaded too early) (thanks to
318
+ Josh Nichols)
319
+ * Factory names ending in 's' no longer cause problems (thanks to Alex Sharp
320
+ and Josh Owens)
321
+
322
+ ## 1.1.3 (September 12, 2008)
323
+ * Automatically pull in definitions from factories.rb, test/factories.rb, or
324
+ spec/factories.rb
325
+ ## 1.1.2 (July 30, 2008)
326
+ * Improved error handling for invalid and undefined factories/attributes
327
+ * Improved handling of strings vs symbols vs classes
328
+ * Added a prettier syntax for handling associations
329
+ * Updated documentation and fixed compatibility with Rails 2.1
330
+
331
+ ## 1.1.1 (June 23, 2008)
332
+ * The attribute "name" no longer requires using #add_attribute
333
+
334
+ ## 1.1.0 (June 03, 2008)
335
+ * Added support for dependent attributes
336
+ * Fixed the attributes_for build strategy to not build associations
337
+ * Added support for sequences
338
+
339
+ ## 1.0.0 (May 31, 2008)
340
+ * First version