faker_maker 2.1.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +13 -14
  3. data/.rubocop.yml +3 -3
  4. data/Gemfile +4 -0
  5. data/README.md +7 -1
  6. data/lib/faker_maker/factory.rb +2 -2
  7. data/lib/faker_maker/version.rb +1 -1
  8. data/lib/faker_maker.rb +1 -1
  9. data/usefakermaker.com/.gitignore +5 -0
  10. data/usefakermaker.com/404.html +25 -0
  11. data/usefakermaker.com/Gemfile +39 -0
  12. data/usefakermaker.com/README.md +5 -0
  13. data/usefakermaker.com/_config.yml +299 -0
  14. data/usefakermaker.com/_config.yml.orig +55 -0
  15. data/usefakermaker.com/_data/navigation.yml +51 -0
  16. data/usefakermaker.com/_data/ui-text.yml +2132 -0
  17. data/usefakermaker.com/_site/assets/css/main.css.map +1 -1
  18. data/usefakermaker.com/_site/assets/js/lunr/lunr-store.js +1 -10
  19. data/usefakermaker.com/_site/feed.xml +1 -17
  20. data/usefakermaker.com/_site/sitemap.xml +0 -10
  21. data/usefakermaker.com/about.markdown +18 -0
  22. data/usefakermaker.com/docs/contributing/index.md +7 -0
  23. data/{docs/installation.md → usefakermaker.com/docs/installing/index.md} +3 -5
  24. data/{docs/usage/arrays.md → usefakermaker.com/docs/usage/arrays/index.md} +2 -6
  25. data/{docs/usage/building_instances.md → usefakermaker.com/docs/usage/building-instances/index.md} +6 -10
  26. data/{docs/usage/chaos.md → usefakermaker.com/docs/usage/chaos/index.md} +6 -10
  27. data/{docs/usage/destroying_factories.md → usefakermaker.com/docs/usage/destroying-factories/index.md} +7 -9
  28. data/{docs/usage/embedding_factories.md → usefakermaker.com/docs/usage/embedding-factories/index.md} +2 -6
  29. data/{docs/usage → usefakermaker.com/docs/usage/getting-started}/index.md +12 -15
  30. data/{docs/usage/audit_logs.md → usefakermaker.com/docs/usage/history-logging/index.md} +4 -4
  31. data/{docs/usage/inheritance.md → usefakermaker.com/docs/usage/inheritance/index.md} +7 -9
  32. data/{docs/usage/json_field_names.md → usefakermaker.com/docs/usage/json-field-names/index.md} +2 -6
  33. data/{docs/usage/lifecycle_hooks.md → usefakermaker.com/docs/usage/lifecycle-hooks/index.md} +3 -7
  34. data/{docs/usage/dependencies.md → usefakermaker.com/docs/usage/managing-dependencies/index.md} +2 -6
  35. data/{docs/usage/omitting_fields copy.md → usefakermaker.com/docs/usage/omitting-fields/index.md} +4 -8
  36. data/usefakermaker.com/pages/index.markdown +27 -0
  37. metadata +29 -32
  38. data/docs/.bundle/config +0 -2
  39. data/docs/.keep +0 -1
  40. data/docs/_config.yml +0 -8
  41. data/docs/contributing.md +0 -9
  42. data/docs/credits.md +0 -9
  43. data/docs/index.md +0 -21
  44. data/docs/logo.png +0 -0
  45. data/usefakermaker.com/_site/404.html +0 -213
  46. data/usefakermaker.com/_site/about/index.html +0 -10
  47. data/usefakermaker.com/_site/index.html +0 -258
  48. data/usefakermaker.com/_site/jekyll/update/welcome-to-jekyll/index.html +0 -18
  49. /data/usefakermaker.com/{_site/assets → assets}/images/pug.png +0 -0
  50. /data/usefakermaker.com/{_site/assets → assets}/images/unipug.svg +0 -0
@@ -1,10 +1 @@
1
- var store = [{
2
- "title": "Welcome to Jekyll!",
3
- "excerpt":"You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated. Jekyll requires blog post files to be named according to the following format: YEAR-MONTH-DAY-title.MARKUP Where YEAR is a four-digit number, MONTH and DAY are both two-digit numbers, and MARKUP is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works. Jekyll also offers powerful support for code snippets: def print_hi(name) puts \"Hi, #{name}\" end print_hi('Tom') #=> prints 'Hi, Tom' to STDOUT. Check out the Jekyll docs for more info on how to get the most out of Jekyll. File all bugs/feature requests at Jekyll’s GitHub repo. If you have questions, you can ask them on Jekyll Talk. ","categories": ["jekyll","update"],
4
- "tags": [],
5
- "url": "/jekyll/update/welcome-to-jekyll/",
6
- "teaser": null
7
- },{
8
- "title": "About",
9
- "excerpt":"This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at jekyllrb.com You can find the source code for Minima at GitHub: jekyll / minima You can find the source code for Jekyll at GitHub: jekyll / jekyll ","url": "http://localhost:4000/about/"
10
- }]
1
+ var store = [,]
@@ -1,17 +1 @@
1
- <?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2024-10-14T16:53:17+01:00</updated><id>http://localhost:4000/feed.xml</id><title type="html">Faker Maker</title><subtitle>Factories over fixtures: cook your test data from fresh</subtitle><author><name>Nigel Brookes-Thomas (Billy Ruffian)</name></author><entry><title type="html">Welcome to Jekyll!</title><link href="http://localhost:4000/jekyll/update/welcome-to-jekyll/" rel="alternate" type="text/html" title="Welcome to Jekyll!" /><published>2024-10-14T13:56:50+01:00</published><updated>2024-10-14T13:56:50+01:00</updated><id>http://localhost:4000/jekyll/update/welcome-to-jekyll</id><content type="html" xml:base="http://localhost:4000/jekyll/update/welcome-to-jekyll/"><![CDATA[<p>You’ll find this post in your <code class="language-plaintext highlighter-rouge">_posts</code> directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run <code class="language-plaintext highlighter-rouge">jekyll serve</code>, which launches a web server and auto-regenerates your site when a file is updated.</p>
2
-
3
- <p>Jekyll requires blog post files to be named according to the following format:</p>
4
-
5
- <p><code class="language-plaintext highlighter-rouge">YEAR-MONTH-DAY-title.MARKUP</code></p>
6
-
7
- <p>Where <code class="language-plaintext highlighter-rouge">YEAR</code> is a four-digit number, <code class="language-plaintext highlighter-rouge">MONTH</code> and <code class="language-plaintext highlighter-rouge">DAY</code> are both two-digit numbers, and <code class="language-plaintext highlighter-rouge">MARKUP</code> is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.</p>
8
-
9
- <p>Jekyll also offers powerful support for code snippets:</p>
10
-
11
- <figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">def</span> <span class="nf">print_hi</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span>
12
- <span class="nb">puts</span> <span class="s2">"Hi, </span><span class="si">#{</span><span class="nb">name</span><span class="si">}</span><span class="s2">"</span>
13
- <span class="k">end</span>
14
- <span class="n">print_hi</span><span class="p">(</span><span class="s1">'Tom'</span><span class="p">)</span>
15
- <span class="c1">#=&gt; prints 'Hi, Tom' to STDOUT.</span></code></pre></figure>
16
-
17
- <p>Check out the <a href="https://jekyllrb.com/docs/home">Jekyll docs</a> for more info on how to get the most out of Jekyll. File all bugs/feature requests at <a href="https://github.com/jekyll/jekyll">Jekyll’s GitHub repo</a>. If you have questions, you can ask them on <a href="https://talk.jekyllrb.com/">Jekyll Talk</a>.</p>]]></content><author><name>Nigel Brookes-Thomas (Billy Ruffian)</name></author><category term="jekyll" /><category term="update" /><summary type="html"><![CDATA[You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.]]></summary></entry></feed>
1
+ <?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2025-01-16T09:57:40+00:00</updated><id>http://localhost:4000/feed.xml</id><title type="html">Faker Maker</title><subtitle>Factories over fixtures: cook your test data from fresh</subtitle><author><name>Nigel Brookes-Thomas (Billy Ruffian)</name></author></feed>
@@ -1,13 +1,3 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
- <url>
4
- <loc>http://localhost:4000/jekyll/update/welcome-to-jekyll/</loc>
5
- <lastmod>2024-10-14T13:56:50+01:00</lastmod>
6
- </url>
7
- <url>
8
- <loc>http://localhost:4000/about/</loc>
9
- </url>
10
- <url>
11
- <loc>http://localhost:4000/</loc>
12
- </url>
13
3
  </urlset>
@@ -0,0 +1,18 @@
1
+ ---
2
+ layout: page
3
+ title: About
4
+ permalink: /about/
5
+ ---
6
+
7
+ This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)
8
+
9
+ You can find the source code for Minima at GitHub:
10
+ [jekyll][jekyll-organization] /
11
+ [minima](https://github.com/jekyll/minima)
12
+
13
+ You can find the source code for Jekyll at GitHub:
14
+ [jekyll][jekyll-organization] /
15
+ [jekyll](https://github.com/jekyll/jekyll)
16
+
17
+
18
+ [jekyll-organization]: https://github.com/jekyll
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: single
3
+ title: Contributing
4
+ nav_order: 2
5
+ ---
6
+
7
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/BillyRuffian/faker_maker>
@@ -1,11 +1,9 @@
1
1
  ---
2
- layout: default
3
- title: Installation
2
+ layout: single
3
+ title: Installing Faker Maker
4
4
  nav_order: 2
5
5
  ---
6
6
 
7
- # Installation
8
-
9
7
  Add this line to your application's Gemfile:
10
8
 
11
9
  ```ruby
@@ -18,4 +16,4 @@ And then execute:
18
16
 
19
17
  Or install it yourself as:
20
18
 
21
- $ gem install faker_maker
19
+ $ gem install faker_maker
@@ -1,12 +1,8 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Arrays
4
- parent: Usage
5
- nav_order: 2
6
4
  ---
7
5
 
8
- # Arrays
9
-
10
6
  It is possible to declare an attribute as having multiple values.
11
7
 
12
8
  ```ruby
@@ -41,4 +37,4 @@ FakerMaker.factory :basket do
41
37
  Faker::Commerce.product_name
42
38
  end
43
39
  end
44
- ```
40
+ ```
@@ -1,13 +1,9 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Building Instances
4
- parent: Usage
5
- nav_order: 6
6
4
  ---
7
5
 
8
- # Building Instances
9
-
10
- Instances are Plain Ol' Ruby Objects and the attributes are attached with getters and setters with their values assigned to the value return from their block at build time.
6
+ Instances are Plain Ol' Ruby Objects and the attributes are attached with getters and setters with their values assigned to the value return from their block at build time.
11
7
 
12
8
  To build an object:
13
9
 
@@ -15,7 +11,7 @@ To build an object:
15
11
  result = FakerMaker[:basket].build
16
12
  ```
17
13
 
18
- will generate a new instance using the Basket factory. Because an actual class is defined, you can instantiate an object directly through `Basket.new` but that will not populate any of the attributes.
14
+ will generate a new instance using the Basket factory. Because an actual class is defined (since v3.0.0 Classes generated by FakerMaker are in the `FakerMaker::Factory` namespace), you can instantiate an object directly through `Basket.new` but that will not populate any of the attributes.
19
15
 
20
16
  It's possible to override attributes at build-time, either by passing values as a hash:
21
17
 
@@ -32,7 +28,7 @@ result = FakerMaker[:item].build{ |i| i.name = 'Electric Sheep' }
32
28
  this is particularly useful for overriding nested values, since all the getters and setters of the embedded objects are already constructed:
33
29
 
34
30
  ```ruby
35
- result = FakerMaker[:basket].build do |b|
31
+ result = FakerMaker[:basket].build do |b|
36
32
  b.items.first.name = 'Neon Badger'
37
33
  end
38
34
  ```
@@ -40,7 +36,7 @@ end
40
36
  if you're crazy enough to want to do both styles during creation, the values in the block will be preserved, e.g.
41
37
 
42
38
  ```ruby
43
- result = FakerMaker[:item].build( name: 'Electric Blanket' ) do |i|
39
+ result = FakerMaker[:item].build( name: 'Electric Blanket' ) do |i|
44
40
  i.name = 'Electric Sheep'
45
41
  end
46
42
  ```
@@ -61,4 +57,4 @@ As another convenience, `FakerMaker` is also assigned to the variable `FM` to it
61
57
 
62
58
  ```ruby
63
59
  result = FM[:basket].build
64
- ```
60
+ ```
@@ -1,17 +1,13 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Chaos
4
- parent: Usage
5
- nav_order: 11
6
4
  ---
7
5
 
8
- # Chaos
6
+ Chaos mode introduces extra spice to your generated factories.
9
7
 
10
- Chaos mode introduces extra spice to your generated factories.
8
+ Attributes can be marked as either `required` or `optional`, which Chaos will use to determine what attributes are included when instantiating your factory.
11
9
 
12
- Attributes can be marked as either `required` or `optional`, which Chaos will use to determine what attributes are included when instantiating your factory.
13
-
14
- Required attributes will always be present, however, optional attributes are not guaranteed to be present when Chaos is enabled.
10
+ Required attributes will always be present, however, optional attributes are not guaranteed to be present when Chaos is enabled.
15
11
 
16
12
  *All attributes are optional by default.*
17
13
 
@@ -26,11 +22,11 @@ FM.factory :item, naming: :json do
26
22
  end
27
23
  ```
28
24
 
29
- You can state an attribute is optional using the `optional` option set to either be a `Boolean`, `Integer` or a `Float`.
25
+ You can state an attribute is optional using the `optional` option set to either be a `Boolean`, `Integer` or a `Float`.
30
26
 
31
27
  When optional is set to either an `Integer` or a `Float`, this overrides the weighting which Chaos uses to determine the likelihood that attribute will be removed.
32
28
 
33
- Higher the value, the more likely that attribute will be present. By default there's a 50/50 chance an optional attribute will be present.
29
+ Higher the value, the more likely that attribute will be present. By default there's a 50/50 chance an optional attribute will be present.
34
30
 
35
31
  To unleash Chaos over a factory, you need to enable it when instantiating your object:
36
32
 
@@ -1,13 +1,11 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Destroying Factories
4
- parent: Usage
5
- nav_order: 9
6
4
  ---
7
5
 
8
6
  ## A Cautionary Tale
9
7
 
10
- If you think you want to do this, you are probably wrong. This will not only de-register the factory from Faker Maker, but also delete the class definition from the interpreter. While it's cool that Ruby allows this, it's almost certainly going to hurt.
8
+ If you think you want to do this, you are probably wrong. This will not only de-register the factory from Faker Maker, but also delete the class definition from the interpreter. While it's cool that Ruby allows this, it's almost certainly going to hurt.
11
9
 
12
10
  This functionality exists for experimenting with factories in REPLs.
13
11
 
@@ -20,11 +18,11 @@ Faker Maker deliberately does not allow you to redefine a factory by redeclaring
20
18
  For example, this might give you unexpected behavior:
21
19
 
22
20
  ```ruby
23
- FakerMaker.factory :user do
21
+ FakerMaker.factory :user do
24
22
  name {'Patsy Stone'}
25
23
  end
26
24
 
27
- FakerMaker.factory :user do
25
+ FakerMaker.factory :user do
28
26
  name {'Patsy Stone'}
29
27
  email {'patsy@fabulous.co.uk'}
30
28
  end
@@ -36,13 +34,13 @@ FM[:user].as_json
36
34
  On the other hand, sometimes you really, really want to destroy a factory and start again (especially if you are experimenting in a REPL for example). FakerMaker allows you to shut a factory which will de-register it from the list of available factories and attempt to unload the class it has built from the Ruby interpreter.
37
35
 
38
36
  ```ruby
39
- FakerMaker.factory :user do
37
+ FakerMaker.factory :user do
40
38
  name {'Patsy Stone'}
41
39
  end
42
40
 
43
41
  FakerMaker.shut!(:user)
44
42
 
45
- FakerMaker.factory :user do
43
+ FakerMaker.factory :user do
46
44
  name {'Patsy Stone'}
47
45
  email {'patsy@fabulous.co.uk'}
48
46
  end
@@ -50,5 +48,5 @@ end
50
48
  FM[:user].as_json
51
49
  => {:name=>"Patsy Stone", :email=>"patsy@fabulous.co.uk"}
52
50
  ```
53
-
51
+
54
52
  It also provides the `shut_all!` method to remove all factories.
@@ -1,12 +1,8 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Embedding Factories
4
- parent: Usage
5
- nav_order: 8
6
4
  ---
7
5
 
8
- # Embedding Factories
9
-
10
6
  To use factories with factories, the following pattern is recommended:
11
7
 
12
8
  ```ruby
@@ -70,4 +66,4 @@ FakerMaker.factory :basket do
70
66
  end
71
67
  ```
72
68
 
73
- With this pattern, you might have to [manage your dependencies]({% link usage/dependencies.md %}) and `require` your referenced factory.
69
+ With this pattern, you might have to [manage your dependencies](../managing-dependencies/) and `require` your referenced factory.
@@ -1,40 +1,37 @@
1
1
  ---
2
- layout: default
3
- title: Usage
4
- nav_order: 3
5
- has_children: true
2
+ layout: single
3
+ title: Getting started
6
4
  ---
7
5
 
8
- # Usage
9
-
10
6
  FakerMaker generates factories that build disposable objects for testing. Each factory has a name and a set of attributes.
11
7
 
12
8
  ```ruby
13
- FakerMaker.factory :user do
9
+ FakerMaker.factory :user do
14
10
  name {'Patsy Stone'}
15
11
  email {'patsy@fabulous.co.uk'}
16
12
  admin {false}
17
13
  end
18
14
  ```
19
15
 
20
- This will generate a `User` class with the attributes `name`, `email` and `admin` which will always return the same value.
16
+ This will generate a `FakerMaker::Factory::User` class with the attributes `name`, `email` and `admin` which will always return the same value.
17
+ Since v3.0.0 Classes generated by FakerMaker are in the `FakerMaker::Factory` namespace.
21
18
 
22
- It is possible to explicitly set the name of class which is particularly useful if there is a risk of redefining an existing one.
19
+ It is possible to explicitly set the name of class which is particularly useful if there is a risk of redefining an existing one. Classes will **always** be created within the `FakerMaker::Factory` namespace (since v3.0.0)
23
20
 
24
21
  ```ruby
25
- FakerMaker.factory :user, class: 'EmailUser' do
22
+ FakerMaker.factory :user, class: 'EmailUser' do
26
23
  name {'Patsy Stone'}
27
24
  email {'patsy@fabulous.co.uk'}
28
25
  admin {false}
29
26
  end
30
27
  ```
31
28
 
32
- The class name will always be turned into a Ruby-style class name so `email_user` would become `EmailUser`.
29
+ The class name will always be turned into a Ruby-style class name so `email_user` would become `FakerMaker::Factory::EmailUser`.
33
30
 
34
31
  Because of the block syntax in Ruby, defining attributes as `Hash`es requires two sets of curly brackets:
35
32
 
36
33
  ```ruby
37
- FakerMaker.factory :response do
34
+ FakerMaker.factory :response do
38
35
  body { { title: 'First Post', content: 'This is part of a hash' } }
39
36
  end
40
37
  ```
@@ -42,7 +39,7 @@ end
42
39
  Blocks are executed in the context of their instance. This means you can refer to variables already defined:
43
40
 
44
41
  ```ruby
45
- FakerMaker.factory :user, class: 'EmailUser' do
42
+ FakerMaker.factory :user, class: 'EmailUser' do
46
43
  title {'Ms'}
47
44
  name {'Patsy Stone'}
48
45
  formal_name {"#{title} #{name}"}
@@ -54,10 +51,10 @@ end
54
51
  Fields with no block (or reference to another factory) will be nil.
55
52
 
56
53
  ```ruby
57
- FakerMaker.factory :request do
54
+ FakerMaker.factory :request do
58
55
  body
59
56
  end
60
57
 
61
58
  FakerMaker[:request].build.body
62
59
  # => nil
63
- ```
60
+ ```
@@ -1,6 +1,6 @@
1
1
  ---
2
- layout: default
3
- title: Audit (History) Logs
2
+ layout: single
3
+ title: History logging
4
4
  parent: Usage
5
5
  nav_order: 10
6
6
  ---
@@ -33,7 +33,7 @@ Immediately after each object is built and after the post-build hooks have compl
33
33
  For example, given the factory:
34
34
 
35
35
  ```ruby
36
- FakerMaker.factory :user do
36
+ FakerMaker.factory :user do
37
37
  name {'Patsy Stone'}
38
38
  email {'patsy@fabulous.co.uk'}
39
39
  admin {false}
@@ -44,4 +44,4 @@ The audit log, on build, would look like:
44
44
 
45
45
  ```
46
46
  {"timestamp":"2023-05-15T15:46:30+01:00","factory":"user","class":"User","body":{"name":"Patsy Stone","email":"patsy@fabulous.co.uk","admin":false}}
47
- ```
47
+ ```
@@ -1,12 +1,8 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Inheritance
4
- parent: Usage
5
- nav_order: 1
6
4
  ---
7
5
 
8
- # Inheritance
9
-
10
6
  FakerMaker can exploit the Ruby class hierarchy to provide additional specialisation or to override some behaviours:
11
7
 
12
8
  ```ruby
@@ -22,16 +18,18 @@ FakerMaker.factory :motorbike, parent: :vehicle do
22
18
  end
23
19
  ```
24
20
 
25
- This is the equivalent of:
21
+ This is the equivalent of:
22
+
23
+ Since v3.0.0 Classes generated by FakerMaker are in the `FakerMaker::Factory` namespace.
26
24
 
27
25
  ```ruby
28
- class Vehicle < Object
26
+ class FakerMaker::Factory::Vehicle < Object
29
27
  # ...
30
28
  end
31
29
 
32
- class Motorbike < Vehicle
30
+ class FakerMaker::Factory::Motorbike < FakerMaker::Factory::Vehicle
33
31
  # ...
34
32
  end
35
33
  ```
36
34
 
37
- so a motorbike will still have a colour and engine capacity between 600 and 2500.
35
+ so a motorbike will still have a colour and engine capacity between 600 and 2500.
@@ -1,12 +1,8 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: JSON Field Names
4
- parent: Usage
5
- nav_order: 4
6
4
  ---
7
5
 
8
- # JSON Field Names
9
-
10
6
  JavaScript likes to use camelCase, Ruby's idiom is to use snake_case. This can make make manipulating factory-built objects in ruby ugly. To avoid this, you can call your fields one thing and ask the JSON outputter to rename the field when generating JSON.
11
7
 
12
8
  Faker Maker provides two mechanisms for dealing with this.
@@ -54,4 +50,4 @@ v.to_json
54
50
 
55
51
  ## Combining the two approaches
56
52
 
57
- If the factory has a `:naming` strategy defined and an attribute has its own `:json` name defined, the attribute's `:json` name will take precedence.
53
+ If the factory has a `:naming` strategy defined and an attribute has its own `:json` name defined, the attribute's `:json` name will take precedence.
@@ -1,12 +1,8 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Lifecycle Hooks
4
- parent: Usage
5
- nav_order: 8
6
4
  ---
7
5
 
8
- # Lifecycle Hooks
9
-
10
6
  Faker Maker has a few hooks which can be added to the factory which are triggered when the factory builds an instance.
11
7
 
12
8
  * `before_build` the instance has been created but none of the values have been set yet
@@ -15,7 +11,7 @@ Faker Maker has a few hooks which can be added to the factory which are triggere
15
11
  For instance:
16
12
 
17
13
  ```ruby
18
- FakerMaker.factory :user do
14
+ FakerMaker.factory :user do
19
15
  before_build do |instance, factory|
20
16
  puts 'Building an instance of User'
21
17
  end
@@ -23,7 +19,7 @@ FakerMaker.factory :user do
23
19
  name {'Patsy Stone'}
24
20
  email {'patsy@fabulous.co.uk'}
25
21
  admin {false}
26
-
22
+
27
23
  after_build do |instance, factory|
28
24
  puts "Built an instance of User (#{instance.name})"
29
25
  end
@@ -1,10 +1,6 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Managing Dependencies
4
- parent: Usage
5
- nav_order: 3
6
4
  ---
7
5
 
8
- # Managing Dependencies
9
-
10
- Factory definition files are Plain Ol' Ruby. If you depend on another factory because you either extend from it or use it just add a `require` or (depending on your load path) `require_relative` to the top of your file.
6
+ Factory definition files are Plain Ol' Ruby. If you depend on another factory because you either extend from it or use it just add a `require` or (depending on your load path) `require_relative` to the top of your file.
@@ -1,16 +1,12 @@
1
1
  ---
2
- layout: default
2
+ layout: single
3
3
  title: Omitting Fields
4
- parent: Usage
5
- nav_order: 5
6
4
  ---
7
5
 
8
- # Omitting Fields
9
-
10
6
  Sometimes you want a field present, other times you don't. This is often the case when you want to skip fields which have null or empty values.
11
7
 
12
8
  ```ruby
13
- FakerMaker.factory :user do
9
+ FakerMaker.factory :user do
14
10
  name {'Patsy Stone'}
15
11
  email(omit: :nil) {'patsy@fabulous.co.uk'}
16
12
  admin {false}
@@ -34,9 +30,9 @@ There are three special modifiers:
34
30
  These can be mixed with real values, e.g.
35
31
 
36
32
  ```ruby
37
- FakerMaker.factory :user do
33
+ FakerMaker.factory :user do
38
34
  name {'Patsy Stone'}
39
35
  email(omit: [:nil, :empty, 'test@foobar.com']) {'patsy@fabulous.co.uk'}
40
36
  admin {false}
41
37
  end
42
- ```
38
+ ```
@@ -0,0 +1,27 @@
1
+ ---
2
+ # Feel free to add content and custom Front Matter to this file.
3
+ # To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults
4
+
5
+ # layout: single
6
+ layout: splash
7
+ permalink: /
8
+ author_profile: false
9
+
10
+ feature_row:
11
+ - image_path: /assets/images/unipug.svg
12
+ alt: An illustration of cute pug dog pretending to be a unicorn by wearing a costume
13
+ title: Factories over fixtures
14
+ excerpt: FakerMaker is a simple factory builder so you can throw away your fixtures and generate test data instead.
15
+ url: "/docs/installing/"
16
+ btn_label: "Get Started"
17
+ btn_class: "btn btn--success"
18
+ ---
19
+
20
+ {% include feature_row type="center" %}
21
+
22
+ Sometimes you need generate data; something testers need to do a lot. Often, a bunch of fixtures will be built by hand, carefully maintained and curated, until the API or schema or something changes and all the fixtures need to be pruned before the tests pass again. This drives testers into building fixtures which individually cover lots of acceptance critera just so that they can drive down the number of them they have to maintain until the fixtures don’t resemble anything like realistic criteria.
23
+
24
+ If you’re testing a Rails application, you can use the awesome FactoryBot to generate faked model instances but what if you’re not using Rails or you don’t have model classes or you’re testing an API? This is what Faker Maker aims to help with.
25
+
26
+ It is designed to resemble the Factory Bot gem but without needing an existing class definition to back its object and so it goes without saying that it offers no persistence mechanism. Its purpose is to provide a simple framework for generating data to test JSON APIs and is intended to be used with the Faker gem (but has no dependency upon it).
27
+
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faker_maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-11-19 00:00:00.000000000 Z
10
+ date: 2025-04-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -206,26 +205,6 @@ files:
206
205
  - _config.yml
207
206
  - bin/console
208
207
  - bin/setup
209
- - docs/.bundle/config
210
- - docs/.keep
211
- - docs/_config.yml
212
- - docs/contributing.md
213
- - docs/credits.md
214
- - docs/index.md
215
- - docs/installation.md
216
- - docs/logo.png
217
- - docs/usage/arrays.md
218
- - docs/usage/audit_logs.md
219
- - docs/usage/building_instances.md
220
- - docs/usage/chaos.md
221
- - docs/usage/dependencies.md
222
- - docs/usage/destroying_factories.md
223
- - docs/usage/embedding_factories.md
224
- - docs/usage/index.md
225
- - docs/usage/inheritance.md
226
- - docs/usage/json_field_names.md
227
- - docs/usage/lifecycle_hooks.md
228
- - docs/usage/omitting_fields copy.md
229
208
  - faker_maker.gemspec
230
209
  - img/unipug.svg
231
210
  - lib/faker_maker.rb
@@ -240,12 +219,16 @@ files:
240
219
  - lib/faker_maker/naming/json.rb
241
220
  - lib/faker_maker/naming/json_capitalized.rb
242
221
  - lib/faker_maker/version.rb
243
- - usefakermaker.com/_site/404.html
244
- - usefakermaker.com/_site/about/index.html
222
+ - usefakermaker.com/.gitignore
223
+ - usefakermaker.com/404.html
224
+ - usefakermaker.com/Gemfile
225
+ - usefakermaker.com/README.md
226
+ - usefakermaker.com/_config.yml
227
+ - usefakermaker.com/_config.yml.orig
228
+ - usefakermaker.com/_data/navigation.yml
229
+ - usefakermaker.com/_data/ui-text.yml
245
230
  - usefakermaker.com/_site/assets/css/main.css
246
231
  - usefakermaker.com/_site/assets/css/main.css.map
247
- - usefakermaker.com/_site/assets/images/pug.png
248
- - usefakermaker.com/_site/assets/images/unipug.svg
249
232
  - usefakermaker.com/_site/assets/js/_main.js
250
233
  - usefakermaker.com/_site/assets/js/lunr/lunr-en.js
251
234
  - usefakermaker.com/_site/assets/js/lunr/lunr-gr.js
@@ -262,10 +245,26 @@ files:
262
245
  - usefakermaker.com/_site/assets/js/plugins/smooth-scroll.js
263
246
  - usefakermaker.com/_site/assets/js/vendor/jquery/jquery-3.6.0.js
264
247
  - usefakermaker.com/_site/feed.xml
265
- - usefakermaker.com/_site/index.html
266
- - usefakermaker.com/_site/jekyll/update/welcome-to-jekyll/index.html
267
248
  - usefakermaker.com/_site/robots.txt
268
249
  - usefakermaker.com/_site/sitemap.xml
250
+ - usefakermaker.com/about.markdown
251
+ - usefakermaker.com/assets/images/pug.png
252
+ - usefakermaker.com/assets/images/unipug.svg
253
+ - usefakermaker.com/docs/contributing/index.md
254
+ - usefakermaker.com/docs/installing/index.md
255
+ - usefakermaker.com/docs/usage/arrays/index.md
256
+ - usefakermaker.com/docs/usage/building-instances/index.md
257
+ - usefakermaker.com/docs/usage/chaos/index.md
258
+ - usefakermaker.com/docs/usage/destroying-factories/index.md
259
+ - usefakermaker.com/docs/usage/embedding-factories/index.md
260
+ - usefakermaker.com/docs/usage/getting-started/index.md
261
+ - usefakermaker.com/docs/usage/history-logging/index.md
262
+ - usefakermaker.com/docs/usage/inheritance/index.md
263
+ - usefakermaker.com/docs/usage/json-field-names/index.md
264
+ - usefakermaker.com/docs/usage/lifecycle-hooks/index.md
265
+ - usefakermaker.com/docs/usage/managing-dependencies/index.md
266
+ - usefakermaker.com/docs/usage/omitting-fields/index.md
267
+ - usefakermaker.com/pages/index.markdown
269
268
  homepage: https://billyruffian.github.io/faker_maker/
270
269
  licenses:
271
270
  - MIT
@@ -273,7 +272,6 @@ metadata:
273
272
  homepage_uri: https://billyruffian.github.io/faker_maker/
274
273
  source_code_uri: https://github.com/BillyRuffian/faker_maker
275
274
  changelog_uri: https://github.com/BillyRuffian/faker_maker/releases
276
- post_install_message:
277
275
  rdoc_options: []
278
276
  require_paths:
279
277
  - lib
@@ -288,8 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
286
  - !ruby/object:Gem::Version
289
287
  version: '0'
290
288
  requirements: []
291
- rubygems_version: 3.5.23
292
- signing_key:
289
+ rubygems_version: 3.6.2
293
290
  specification_version: 4
294
291
  summary: FakerMaker bakes fakes.
295
292
  test_files: []
data/docs/.bundle/config DELETED
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_JOBS: "12"
data/docs/.keep DELETED
@@ -1 +0,0 @@
1
-