factory_bot 4.11.1 → 6.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +58 -13
  3. data/GETTING_STARTED.md +825 -153
  4. data/LICENSE +1 -1
  5. data/NEWS.md +385 -0
  6. data/README.md +20 -30
  7. data/lib/factory_bot/aliases.rb +3 -3
  8. data/lib/factory_bot/attribute/association.rb +2 -2
  9. data/lib/factory_bot/attribute/dynamic.rb +3 -2
  10. data/lib/factory_bot/attribute.rb +4 -39
  11. data/lib/factory_bot/attribute_assigner.rb +27 -12
  12. data/lib/factory_bot/attribute_list.rb +3 -2
  13. data/lib/factory_bot/callback.rb +4 -11
  14. data/lib/factory_bot/configuration.rb +15 -19
  15. data/lib/factory_bot/declaration/association.rb +33 -3
  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.rb +5 -5
  19. data/lib/factory_bot/declaration_list.rb +3 -3
  20. data/lib/factory_bot/decorator/attribute_hash.rb +1 -1
  21. data/lib/factory_bot/decorator/invocation_tracker.rb +2 -1
  22. data/lib/factory_bot/decorator.rb +20 -4
  23. data/lib/factory_bot/definition.rb +69 -21
  24. data/lib/factory_bot/definition_hierarchy.rb +1 -11
  25. data/lib/factory_bot/definition_proxy.rb +119 -64
  26. data/lib/factory_bot/enum.rb +27 -0
  27. data/lib/factory_bot/errors.rb +7 -4
  28. data/lib/factory_bot/evaluation.rb +1 -1
  29. data/lib/factory_bot/evaluator.rb +10 -11
  30. data/lib/factory_bot/evaluator_class_definer.rb +1 -1
  31. data/lib/factory_bot/factory.rb +12 -12
  32. data/lib/factory_bot/factory_runner.rb +4 -4
  33. data/lib/factory_bot/find_definitions.rb +2 -2
  34. data/lib/factory_bot/internal.rb +91 -0
  35. data/lib/factory_bot/linter.rb +41 -28
  36. data/lib/factory_bot/null_factory.rb +13 -4
  37. data/lib/factory_bot/null_object.rb +2 -6
  38. data/lib/factory_bot/registry.rb +17 -8
  39. data/lib/factory_bot/reload.rb +2 -3
  40. data/lib/factory_bot/sequence.rb +5 -6
  41. data/lib/factory_bot/strategy/attributes_for.rb +4 -0
  42. data/lib/factory_bot/strategy/build.rb +4 -0
  43. data/lib/factory_bot/strategy/create.rb +4 -0
  44. data/lib/factory_bot/strategy/null.rb +4 -0
  45. data/lib/factory_bot/strategy/stub.rb +41 -32
  46. data/lib/factory_bot/strategy_calculator.rb +1 -1
  47. data/lib/factory_bot/strategy_syntax_method_registrar.rb +13 -2
  48. data/lib/factory_bot/syntax/default.rb +13 -25
  49. data/lib/factory_bot/syntax/methods.rb +32 -9
  50. data/lib/factory_bot/syntax.rb +2 -2
  51. data/lib/factory_bot/trait.rb +7 -4
  52. data/lib/factory_bot/version.rb +1 -1
  53. data/lib/factory_bot.rb +71 -140
  54. metadata +46 -34
  55. data/NEWS +0 -306
  56. data/lib/factory_bot/attribute/static.rb +0 -16
  57. data/lib/factory_bot/declaration/static.rb +0 -26
  58. 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: 14d67d2d0498cdfe3d47717279561f299566ecd20084af6958e3c5143188ccae
4
- data.tar.gz: bb6daffb31d969293032bbb2d655c3628095bdd285708fdc93fe2a60e4cd072e
3
+ metadata.gz: 3bcbbd8bee01abdb25a5cfdbbbbca29396f587236f0c20f8300adbf6e32f783c
4
+ data.tar.gz: 94d8e73507ae61edba7fb3129ee74c4fe9998a8fb78614ecba9966199561c8e4
5
5
  SHA512:
6
- metadata.gz: 24178c541ce3b726ad7274febd2bbf69ccaff9446a15a79b9bfce5525b0e2f63cc4af50a48950abe5b8b80397151bf86c31263463b0d7309093c870cb925c97d
7
- data.tar.gz: 630e120e664a503de162d11d9dc36f83a7fc5602a8935875cacfb905b28c3cf1c8f0978137281b5aa8d2fed3fa40c236dd567cb7544bca44cb85e1f43fb2ac83
6
+ metadata.gz: e97d9530810f0de00f6e0129df37db52722ee8d430f7b118ffdcebdc0eecc1e1532356b7c8e01cc85265c04f18eb174d3d5ff09fe235c5f30ceb7b5e16432508
7
+ data.tar.gz: 71b77c30b16c89588d6946505be547374321597e8e16f89673766cda94b22188dc28070a34144ae126dad93042de0173e1d92173237ae1e929a3131e85569a51
data/CONTRIBUTING.md CHANGED
@@ -12,7 +12,7 @@ Here are some ways *you* can contribute:
12
12
  * by suggesting new features
13
13
  * by writing or editing documentation
14
14
  * by writing specifications
15
- * by writing code ( **no patch is too small** : fix typos, add comments, clean up inconsistent whitespace )
15
+ * by writing code ( **no patch is too small** : fix typos, add comments, etc. )
16
16
  * by refactoring code
17
17
  * by closing [issues][]
18
18
  * by reviewing patches
@@ -23,13 +23,10 @@ Here are some ways *you* can contribute:
23
23
 
24
24
  * We use the [GitHub issue tracker][issues] to track bugs and features.
25
25
  * Before submitting a bug report or feature request, check to make sure it hasn't
26
- already been submitted.
27
- * When submitting a bug report, please include a [Gist][] that includes a stack
28
- trace and any details that may be necessary to reproduce the bug, including
29
- your gem version, Ruby version, and operating system. Ideally, a bug report
30
- should include a pull request with failing specs.
31
-
32
- [gist]: https://gist.github.com/
26
+ already been submitted.
27
+ * When submitting a bug report, please include a [reproduction script] and any
28
+ other details that may be necessary to reproduce the bug, including your gem
29
+ version, Ruby version, and operating system.
33
30
 
34
31
  ## Cleaning up issues
35
32
 
@@ -40,21 +37,69 @@ already been submitted.
40
37
  We will happily reopen the issue.
41
38
 
42
39
  ## Submitting a Pull Request
40
+
43
41
  1. [Fork][fork] the [official repository][repo].
44
- 2. [Create a topic branch.][branch]
45
- 3. Implement your feature or bug fix.
46
- 4. Add, commit, and push your changes.
47
- 5. [Submit a pull request.][pr]
42
+ 1. [Create a topic branch.][branch]
43
+ 1. Implement your feature or bug fix.
44
+ 1. Add, commit, and push your changes.
45
+ 1. [Submit a pull request.][pr]
46
+
47
+ ### Notes
48
48
 
49
- ## Notes
50
49
  * Please add tests if you changed code. Contributions without tests won't be accepted.
51
50
  * If you don't know how to add tests, please put in a PR and leave a comment
52
51
  asking for help. We love helping!
53
52
  * Please don't update the Gem version.
54
53
 
54
+ ## Setting up
55
+
56
+ ```sh
57
+ bundle install
58
+ ```
59
+
60
+ ## Running the test suite
61
+
62
+ The default rake task will run the full test suite and [standard]:
63
+
64
+ ```sh
65
+ bundle exec rake
66
+ ```
67
+
68
+ You can also run a single group of tests (unit, spec, or feature)
69
+
70
+ ```sh
71
+ bundle exec rake spec:unit
72
+ bundle exec rake spec:acceptance
73
+ bundle exec rake features
74
+ ```
75
+
76
+ To run an individual rspec test, you can provide a path and line number:
77
+
78
+ ```sh
79
+ bundle exec rspec spec/path/to/spec.rb:123
80
+ ```
81
+
82
+ You can run tests with a specific version of rails via [appraisal]. To run
83
+ the default rake task against Rails 6, for example:
84
+
85
+ ```sh
86
+ bundle exec appraisal 6.0 rake
87
+ ```
88
+
89
+ ## Formatting
90
+
91
+ Use [standard] to automatically format your code:
92
+
93
+ ```sh
94
+ bundle exec rake standard:fix
95
+ ```
96
+
55
97
  [repo]: https://github.com/thoughtbot/factory_bot/tree/master
56
98
  [fork]: https://help.github.com/articles/fork-a-repo/
57
99
  [branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
58
100
  [pr]: https://help.github.com/articles/using-pull-requests/
101
+ [standard]: https://github.com/testdouble/standard
102
+ [appraisal]: https://github.com/thoughtbot/appraisal
103
+ [reproduction script]: https://github.com/thoughtbot/factory_bot/blob/master/.github/REPRODUCTION_SCRIPT.rb
59
104
 
60
105
  Inspired by https://github.com/middleman/middleman-heroku/blob/master/CONTRIBUTING.md