faker_maker 1.2.1 → 2.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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +37 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +10 -1
- data/Guardfile +1 -1
- data/bin/console +1 -0
- data/docs/usage/audit_logs.md +47 -0
- data/docs/usage/chaos.md +45 -0
- data/faker_maker.gemspec +3 -5
- data/lib/faker_maker/attribute.rb +23 -3
- data/lib/faker_maker/auditable.rb +35 -0
- data/lib/faker_maker/configuration.rb +34 -0
- data/lib/faker_maker/factory.rb +100 -9
- data/lib/faker_maker/lifecycle_hooks.rb +4 -4
- data/lib/faker_maker/version.rb +1 -1
- data/lib/faker_maker.rb +6 -0
- metadata +13 -38
- data/.circleci/config.yml +0 -13
- data/.coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc9201db222f65f8df79f92edc882d9d76e5ca21c6220b377f5e86ce9414d287
|
4
|
+
data.tar.gz: d4601f347ce1231fd287d33addde2bb83c00a1a770783eec8007dd7417c6c2f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce1be4538d82898bb1accd89585485e6072974350088261dece5f0481a3d1950cbf1462dba6363231e2b25019632d8f1aa649e04cab5c4a0a752c6ca9e428c7f
|
7
|
+
data.tar.gz: 2d442d69c483b0aa5ba5f7bc9fd26396376edbc2ff700c9d47305d27f2fc809d42d4971bf8ef8b09c67f7f4912395e6eb0127c0d105e6763708f342916e2ae85
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
pull_request:
|
13
|
+
branches: [ "master" ]
|
14
|
+
|
15
|
+
permissions:
|
16
|
+
contents: read
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
test:
|
20
|
+
|
21
|
+
runs-on: ubuntu-latest
|
22
|
+
strategy:
|
23
|
+
matrix:
|
24
|
+
ruby-version: ["3.0", "3.1", "3.2"]
|
25
|
+
|
26
|
+
steps:
|
27
|
+
- uses: actions/checkout@v3
|
28
|
+
- name: Set up Ruby
|
29
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
30
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
31
|
+
# uses: ruby/setup-ruby@v1
|
32
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby-version }}
|
35
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
36
|
+
- name: Run tests
|
37
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Guardfile
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
#
|
18
18
|
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
19
|
|
20
|
-
#
|
20
|
+
# NOTE: The cmd option is now required due to the increasing number of ways
|
21
21
|
# rspec may be run, below are examples of the most common uses.
|
22
22
|
# * bundler: 'bundle exec rspec'
|
23
23
|
# * bundler binstubs: 'bin/rspec'
|
data/bin/console
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Audit (History) Logs
|
4
|
+
parent: Usage
|
5
|
+
nav_order: 10
|
6
|
+
---
|
7
|
+
|
8
|
+
_(since 1.3.0)_
|
9
|
+
|
10
|
+
# Audit logs
|
11
|
+
|
12
|
+
It might be useful to collect the history of all the fakes generated by your factories. FakerMaker allows you to stream (or write to a file) all the instances it builds for you. This is optional and disabled by default.
|
13
|
+
|
14
|
+
## Enable logging
|
15
|
+
|
16
|
+
By default audit logging is disabled. The default output stream is `STDOUT`. The output target can either be an object that responds to `puts`, or be a string which will be interpreted as a file location to use to write to. If file path string is used, it will be opened in 'append' mode.
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
FakerMaker.configure do |config|
|
20
|
+
config.audit = true
|
21
|
+
config.audit_destination = '/tmp/faker_maker_audit_logs'
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
## Audit streams
|
26
|
+
|
27
|
+
Immediately after each object is built and after the post-build hooks have completed, the instance details will be logged in line-delimited JSON (JSONL), to the stream or file. Each line is contained in an envelope containing the following metadata:
|
28
|
+
|
29
|
+
* The timestamp at the time of logging
|
30
|
+
* The name of factory
|
31
|
+
* The class name of the object the factory instantiated
|
32
|
+
|
33
|
+
For example, given the factory:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
FakerMaker.factory :user do
|
37
|
+
name {'Patsy Stone'}
|
38
|
+
email {'patsy@fabulous.co.uk'}
|
39
|
+
admin {false}
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
The audit log, on build, would look like:
|
44
|
+
|
45
|
+
```
|
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
|
+
```
|
data/docs/usage/chaos.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Chaos
|
4
|
+
parent: Usage
|
5
|
+
nav_order: 11
|
6
|
+
---
|
7
|
+
|
8
|
+
# Chaos
|
9
|
+
|
10
|
+
Chaos mode introduces extra spice to your generated factories.
|
11
|
+
|
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.
|
15
|
+
|
16
|
+
*All attributes are optional by default.*
|
17
|
+
|
18
|
+
To explicitly mark attributes as either required or optional:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
FM.factory :item, naming: :json do
|
22
|
+
name { 'Blanket' }
|
23
|
+
price(required: true) { 100 }
|
24
|
+
description(optional: true) { 'Keeps you warm and cozy' }
|
25
|
+
manufacturer(optional: 0.7) { 'A large fruit company' }
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
You can state an attribute is optional using the `optional` option set to either be a `Boolean`, `Integer` or a `Float`.
|
30
|
+
|
31
|
+
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
|
+
|
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.
|
34
|
+
|
35
|
+
To unleash Chaos over a factory, you need to enable it when instantiating your object:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
result = FakerMaker[:item].build( chaos: true )
|
39
|
+
```
|
40
|
+
|
41
|
+
You can also specify which attributes Chaos can use when instantiating your object:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
result = FakerMaker[:item].build( chaos: %i[name manufacturer] )
|
45
|
+
```
|
data/faker_maker.gemspec
CHANGED
@@ -41,10 +41,10 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
42
42
|
spec.require_paths = ['lib']
|
43
43
|
|
44
|
-
spec.add_dependency 'activesupport', '>= 5.2', '<
|
44
|
+
spec.add_dependency 'activesupport', '>= 5.2', '< 8'
|
45
45
|
|
46
46
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
47
|
-
spec.add_development_dependency 'faker', '~> 2
|
47
|
+
spec.add_development_dependency 'faker', '~> 3.2'
|
48
48
|
spec.add_development_dependency 'guard', '~> 2.16'
|
49
49
|
spec.add_development_dependency 'guard-bundler', '~> 3.0'
|
50
50
|
spec.add_development_dependency 'guard-rubocop', '~> 1.3'
|
@@ -53,8 +53,6 @@ Gem::Specification.new do |spec|
|
|
53
53
|
spec.add_development_dependency 'rake', '~> 13.0'
|
54
54
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
55
55
|
spec.add_development_dependency 'rubocop', '~> 1.0'
|
56
|
-
spec.add_development_dependency 'simplecov', '~> 0.16'
|
57
|
-
spec.add_development_dependency 'coveralls', '~> 0.8'
|
58
56
|
|
59
|
-
spec.required_ruby_version = '>=
|
57
|
+
spec.required_ruby_version = '>= 3.0'
|
60
58
|
end
|
@@ -3,16 +3,25 @@
|
|
3
3
|
module FakerMaker
|
4
4
|
# Attributes describe the fields of classes
|
5
5
|
class Attribute
|
6
|
-
attr_reader :name, :block, :translation
|
6
|
+
attr_reader :name, :block, :translation, :required, :optional, :optional_weighting
|
7
|
+
|
8
|
+
DEFAULT_OPTIONAL_WEIGHTING = 0.5
|
7
9
|
|
8
10
|
def initialize( name, block = nil, options = {} )
|
9
11
|
assert_valid_options options
|
10
12
|
@name = name
|
11
|
-
@block = block || proc {
|
13
|
+
@block = block || proc {}
|
12
14
|
@cardinality = options[:has] || 1
|
13
15
|
@translation = options[:json]
|
14
16
|
@omit = *options[:omit]
|
15
17
|
@array = options[:array] == true
|
18
|
+
|
19
|
+
if options[:required].to_s.downcase.eql?('true') || options[:optional].to_s.downcase.eql?('false')
|
20
|
+
@required = true
|
21
|
+
else
|
22
|
+
@optional = true
|
23
|
+
@optional_weighting = determine_optional_weighting(options[:optional])
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
def array?
|
@@ -49,7 +58,18 @@ module FakerMaker
|
|
49
58
|
end
|
50
59
|
|
51
60
|
def assert_valid_options( options )
|
52
|
-
options.assert_valid_keys :has, :array, :json, :omit
|
61
|
+
options.assert_valid_keys :has, :array, :json, :omit, :required, :optional
|
62
|
+
end
|
63
|
+
|
64
|
+
def determine_optional_weighting( value )
|
65
|
+
case value
|
66
|
+
when Float
|
67
|
+
value.between?(0, 1) ? value : (value / 100)
|
68
|
+
when Integer
|
69
|
+
value.ceil.between?(0, 100) ? (value.to_f / 100) : DEFAULT_OPTIONAL_WEIGHTING
|
70
|
+
else
|
71
|
+
DEFAULT_OPTIONAL_WEIGHTING
|
72
|
+
end
|
53
73
|
end
|
54
74
|
end
|
55
75
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# FakerMaker module for generating Fakes
|
4
|
+
module FakerMaker
|
5
|
+
# Mix-in module which provides the auditable functionality
|
6
|
+
module Auditable
|
7
|
+
def audit(instance)
|
8
|
+
envelope = audit_envelope(class: instance.class.name, body: instance.as_json)
|
9
|
+
audit_stream.puts(JSON.generate(envelope))
|
10
|
+
audit_stream.flush if audit_stream.respond_to?(:flush)
|
11
|
+
rescue StandardError => e
|
12
|
+
warn "FakerMaker Warning: #{e.class}: \"#{e.message}\" occurred. FakerMaker will disable audit logging. " \
|
13
|
+
'Further warnings supressed.'
|
14
|
+
FakerMaker.configuration.audit = false
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def audit_stream
|
20
|
+
destination = FakerMaker.configuration.audit_destination
|
21
|
+
return destination if destination.respond_to?(:puts)
|
22
|
+
|
23
|
+
file_destination = File.new(destination, 'a')
|
24
|
+
FakerMaker.configuration.audit_destination = file_destination
|
25
|
+
end
|
26
|
+
|
27
|
+
def audit_envelope(**overrides)
|
28
|
+
{
|
29
|
+
timestamp: DateTime.now.iso8601,
|
30
|
+
factory: name.to_s,
|
31
|
+
**overrides
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# FakerMaker module for generating Fakes
|
4
|
+
module FakerMaker
|
5
|
+
# Configuration class, holds all the config options for FM
|
6
|
+
class Configuration
|
7
|
+
attr_writer :audit
|
8
|
+
attr_accessor :audit_destination
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@audit = false
|
12
|
+
@audit_destination = $stdout
|
13
|
+
end
|
14
|
+
|
15
|
+
def audit?
|
16
|
+
@audit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Mixin to provide configuraton methods to an extending or implementing class
|
21
|
+
module Configurable
|
22
|
+
def configuration
|
23
|
+
@configuration ||= Configuration.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def configuration=(config)
|
27
|
+
@configuration = config
|
28
|
+
end
|
29
|
+
|
30
|
+
def configure
|
31
|
+
yield(configuration) if block_given?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/faker_maker/factory.rb
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
module FakerMaker
|
5
5
|
# Factories construct instances of a fake
|
6
6
|
class Factory
|
7
|
-
|
7
|
+
include Auditable
|
8
|
+
attr_reader :name, :class_name, :parent, :chaos_selected_attributes
|
8
9
|
|
9
10
|
def initialize( name, options = {} )
|
10
11
|
assert_valid_options options
|
@@ -18,7 +19,7 @@ module FakerMaker
|
|
18
19
|
when nil
|
19
20
|
nil
|
20
21
|
else
|
21
|
-
raise FakerMaker::NoSuchAttributeNamingStrategy,
|
22
|
+
raise FakerMaker::NoSuchAttributeNamingStrategy, options[:naming]
|
22
23
|
end
|
23
24
|
@attributes = []
|
24
25
|
@klass = nil
|
@@ -41,13 +42,25 @@ module FakerMaker
|
|
41
42
|
@instance ||= instantiate
|
42
43
|
end
|
43
44
|
|
44
|
-
def build( attributes
|
45
|
+
def build( attributes: {}, chaos: false, **kwargs )
|
46
|
+
if kwargs.present?
|
47
|
+
validate_deprecated_build(kwargs)
|
48
|
+
attributes = kwargs
|
49
|
+
end
|
50
|
+
|
45
51
|
@instance = nil
|
46
52
|
before_build if respond_to? :before_build
|
47
53
|
assert_only_known_attributes_for_override( attributes )
|
48
|
-
|
54
|
+
|
55
|
+
assert_chaos_options chaos if chaos
|
56
|
+
|
57
|
+
optional_attributes
|
58
|
+
required_attributes
|
59
|
+
|
60
|
+
populate_instance instance, attributes, chaos
|
49
61
|
yield instance if block_given?
|
50
62
|
after_build if respond_to? :after_build
|
63
|
+
audit(@instance) if FakerMaker.configuration.audit?
|
51
64
|
instance
|
52
65
|
end
|
53
66
|
|
@@ -108,11 +121,14 @@ module FakerMaker
|
|
108
121
|
|
109
122
|
protected
|
110
123
|
|
111
|
-
def populate_instance( instance, attr_override_values )
|
112
|
-
FakerMaker[parent].populate_instance instance, attr_override_values if parent?
|
113
|
-
|
114
|
-
|
115
|
-
|
124
|
+
def populate_instance( instance, attr_override_values, chaos )
|
125
|
+
FakerMaker[parent].populate_instance instance, attr_override_values, chaos if parent?
|
126
|
+
|
127
|
+
attributes = chaos ? chaos_select(chaos) : @attributes
|
128
|
+
|
129
|
+
attributes.each do |attribute|
|
130
|
+
value = value_for_attribute( instance, attribute, attr_override_values )
|
131
|
+
instance.send "#{attribute.name}=", value
|
116
132
|
end
|
117
133
|
instance.instance_variable_set( :@fm_factory, self )
|
118
134
|
end
|
@@ -126,6 +142,19 @@ module FakerMaker
|
|
126
142
|
raise FakerMaker::NoSuchAttributeError, issue unless unknown_attrs.empty?
|
127
143
|
end
|
128
144
|
|
145
|
+
def assert_only_known_and_optional_attributes_for_chaos( chaos_attr_values )
|
146
|
+
chaos_attr_values = chaos_attr_values.map(&:to_sym)
|
147
|
+
unknown_attrs = chaos_attr_values - attribute_names
|
148
|
+
issue = "Can't build an instance of '#{class_name}' " \
|
149
|
+
"setting '#{unknown_attrs.join( ', ' )}', no such attribute(s)"
|
150
|
+
raise FakerMaker::NoSuchAttributeError, issue unless unknown_attrs.empty?
|
151
|
+
|
152
|
+
# Are any chaos attributes marked as required?
|
153
|
+
conflicting_attributes = chaos_attr_values.select { |attr| required_attributes.map(&:name).include? attr }
|
154
|
+
issue = "Can't use chaos on a required attribute: '#{conflicting_attributes}'"
|
155
|
+
raise FakerMaker::ChaosConflictingAttributeError, issue unless conflicting_attributes.empty?
|
156
|
+
end
|
157
|
+
|
129
158
|
def attribute_hash_overridden_value?( attr, attr_override_values )
|
130
159
|
attr_override_values.keys.include?( attr.name )
|
131
160
|
end
|
@@ -162,6 +191,68 @@ module FakerMaker
|
|
162
191
|
def assert_valid_options( options )
|
163
192
|
options.assert_valid_keys :class, :parent, :naming
|
164
193
|
end
|
194
|
+
|
195
|
+
# Asserts attributes passed in for chaos mode are valid
|
196
|
+
def assert_chaos_options( chaos )
|
197
|
+
eval = -> { [Array, String, TrueClass, FalseClass, Symbol].include? chaos.class }
|
198
|
+
msg = "chaos: arg does not support object of type: '#{chaos.class}'"
|
199
|
+
raise NoSuchAttributeError, msg unless eval.call
|
200
|
+
|
201
|
+
case chaos
|
202
|
+
when Array
|
203
|
+
assert_only_known_and_optional_attributes_for_chaos(chaos)
|
204
|
+
when String, Symbol
|
205
|
+
assert_only_known_and_optional_attributes_for_chaos([chaos])
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Selects required @attributes
|
210
|
+
def required_attributes
|
211
|
+
@required_attributes ||= @attributes.select { |attr| attr.required.eql? true }
|
212
|
+
end
|
213
|
+
|
214
|
+
# Selects optional @attributes
|
215
|
+
def optional_attributes
|
216
|
+
@optional_attributes ||= @attributes.select(&:optional)
|
217
|
+
end
|
218
|
+
|
219
|
+
# Randomly selects optional attributes
|
220
|
+
# Attributes selected from parent will also be selected for the child
|
221
|
+
# @param [Array || TrueClass] chaos_attrs
|
222
|
+
# @return [Array]
|
223
|
+
def chaos_select( chaos_attrs = [] )
|
224
|
+
selected_attrs = []
|
225
|
+
optional_attrs = optional_attributes.dup
|
226
|
+
|
227
|
+
# Filter specific optional attributes if present
|
228
|
+
if chaos_attrs.is_a?(Array) && chaos_attrs.size.positive?
|
229
|
+
optional_attrs, selected_attrs = optional_attrs.partition { |attr| chaos_attrs.include?(attr.name) }
|
230
|
+
end
|
231
|
+
|
232
|
+
# Grab parent selected attributes
|
233
|
+
@chaos_selected_attributes = parent? ? FakerMaker[parent].chaos_selected_attributes : []
|
234
|
+
selected_inherited_attr = optional_attrs.select do |attr|
|
235
|
+
@chaos_selected_attributes.map(&:name).include? attr.name
|
236
|
+
end
|
237
|
+
|
238
|
+
# Select optional attributes based on weighting
|
239
|
+
optional_attrs.each do |optional_attr|
|
240
|
+
selected_attrs.push(optional_attr) if Random.rand < optional_attr.optional_weighting
|
241
|
+
end
|
242
|
+
|
243
|
+
# Concat required, selected and parent attributes
|
244
|
+
@chaos_selected_attributes.concat(required_attributes)
|
245
|
+
.concat(selected_inherited_attr)
|
246
|
+
.concat(selected_attrs).uniq!
|
247
|
+
@chaos_selected_attributes
|
248
|
+
end
|
249
|
+
|
250
|
+
def validate_deprecated_build(kwargs)
|
251
|
+
usage = kwargs.each_with_object([]) { |kwarg, result| result << "#{kwarg.first}: #{kwarg.last}" }.join(', ')
|
252
|
+
|
253
|
+
warn "[DEPRECATION] `FM[:#{name}].build(#{usage})` is deprecated. " \
|
254
|
+
"Please use `FM[:#{name}].build(attributes: { #{usage} })` instead."
|
255
|
+
end
|
165
256
|
end
|
166
257
|
end
|
167
258
|
# rubocop:enable Metrics/ClassLength
|
@@ -4,12 +4,12 @@ module FakerMaker
|
|
4
4
|
module LifecycleHooks
|
5
5
|
# Lifecycle hooks which can be called during the building of an instance
|
6
6
|
module DefinitionProxy
|
7
|
-
def before_build
|
8
|
-
@factory.define_singleton_method(:before_build) { yield(
|
7
|
+
def before_build
|
8
|
+
@factory.define_singleton_method(:before_build) { yield(instance, self) }
|
9
9
|
end
|
10
10
|
|
11
|
-
def after_build
|
12
|
-
@factory.define_singleton_method(:after_build) { yield(
|
11
|
+
def after_build
|
12
|
+
@factory.define_singleton_method(:after_build) { yield(instance, self) }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/faker_maker/version.rb
CHANGED
data/lib/faker_maker.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'time'
|
4
|
+
|
3
5
|
require 'active_support'
|
4
6
|
require 'active_support/core_ext/hash'
|
5
7
|
require 'active_support/core_ext/object/json'
|
6
8
|
require 'active_support/core_ext/string'
|
7
9
|
require 'faker_maker/attribute'
|
10
|
+
require 'faker_maker/auditable'
|
8
11
|
require 'faker_maker/base'
|
12
|
+
require 'faker_maker/configuration'
|
9
13
|
require 'faker_maker/lifecycle_hooks'
|
10
14
|
require 'faker_maker/definition_proxy'
|
11
15
|
require 'faker_maker/factory'
|
@@ -18,10 +22,12 @@ require 'faker_maker/version'
|
|
18
22
|
# FakerMaker module for generating Fakes
|
19
23
|
module FakerMaker
|
20
24
|
extend FakerMaker::Base
|
25
|
+
extend FakerMaker::Configurable
|
21
26
|
|
22
27
|
class Error < StandardError; end
|
23
28
|
class NoSuchFactoryError < StandardError; end
|
24
29
|
class NoSuchAttributeError < StandardError; end
|
30
|
+
class ChaosConflictingAttributeError < StandardError; end
|
25
31
|
class NoSuchAttributeNamingStrategy < StandardError; end
|
26
32
|
# Your code goes here...
|
27
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faker_maker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Brookes-Thomas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '2
|
53
|
+
version: '3.2'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '2
|
60
|
+
version: '3.2'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: guard
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,34 +170,6 @@ dependencies:
|
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '1.0'
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: simplecov
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '0.16'
|
180
|
-
type: :development
|
181
|
-
prerelease: false
|
182
|
-
version_requirements: !ruby/object:Gem::Requirement
|
183
|
-
requirements:
|
184
|
-
- - "~>"
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: '0.16'
|
187
|
-
- !ruby/object:Gem::Dependency
|
188
|
-
name: coveralls
|
189
|
-
requirement: !ruby/object:Gem::Requirement
|
190
|
-
requirements:
|
191
|
-
- - "~>"
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: '0.8'
|
194
|
-
type: :development
|
195
|
-
prerelease: false
|
196
|
-
version_requirements: !ruby/object:Gem::Requirement
|
197
|
-
requirements:
|
198
|
-
- - "~>"
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: '0.8'
|
201
173
|
description: FakerMaker is a simple factory builder so you can throw away your fixtures
|
202
174
|
and generate test data instead.
|
203
175
|
email:
|
@@ -206,9 +178,8 @@ executables: []
|
|
206
178
|
extensions: []
|
207
179
|
extra_rdoc_files: []
|
208
180
|
files:
|
209
|
-
- ".circleci/config.yml"
|
210
|
-
- ".coveralls.yml"
|
211
181
|
- ".github/dependabot.yml"
|
182
|
+
- ".github/workflows/ruby.yml"
|
212
183
|
- ".gitignore"
|
213
184
|
- ".rspec"
|
214
185
|
- ".rubocop.yml"
|
@@ -230,7 +201,9 @@ files:
|
|
230
201
|
- docs/installation.md
|
231
202
|
- docs/logo.png
|
232
203
|
- docs/usage/arrays.md
|
204
|
+
- docs/usage/audit_logs.md
|
233
205
|
- docs/usage/building_instances.md
|
206
|
+
- docs/usage/chaos.md
|
234
207
|
- docs/usage/dependencies.md
|
235
208
|
- docs/usage/destroying_factories.md
|
236
209
|
- docs/usage/embedding_factories.md
|
@@ -243,7 +216,9 @@ files:
|
|
243
216
|
- img/unipug.svg
|
244
217
|
- lib/faker_maker.rb
|
245
218
|
- lib/faker_maker/attribute.rb
|
219
|
+
- lib/faker_maker/auditable.rb
|
246
220
|
- lib/faker_maker/base.rb
|
221
|
+
- lib/faker_maker/configuration.rb
|
247
222
|
- lib/faker_maker/definition_proxy.rb
|
248
223
|
- lib/faker_maker/factory.rb
|
249
224
|
- lib/faker_maker/lifecycle_hooks.rb
|
@@ -266,14 +241,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
266
241
|
requirements:
|
267
242
|
- - ">="
|
268
243
|
- !ruby/object:Gem::Version
|
269
|
-
version: '
|
244
|
+
version: '3.0'
|
270
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
246
|
requirements:
|
272
247
|
- - ">="
|
273
248
|
- !ruby/object:Gem::Version
|
274
249
|
version: '0'
|
275
250
|
requirements: []
|
276
|
-
rubygems_version: 3.
|
251
|
+
rubygems_version: 3.4.10
|
277
252
|
signing_key:
|
278
253
|
specification_version: 4
|
279
254
|
summary: FakerMaker bakes fakes.
|
data/.circleci/config.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Use the latest 2.1 version of CircleCI pipeline processing engine, see https://circleci.com/docs/2.0/configuration-reference/
|
2
|
-
version: 2.1
|
3
|
-
|
4
|
-
jobs:
|
5
|
-
build:
|
6
|
-
docker:
|
7
|
-
- image: circleci/ruby:2.6.3-stretch-node
|
8
|
-
steps:
|
9
|
-
- checkout
|
10
|
-
- run: gem update --system
|
11
|
-
- run: gem install bundler
|
12
|
-
- run: bundle install
|
13
|
-
- run: bundle exec rake spec
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
repo_token: K7czIqoKhrE9BRBk1ubEToyJkLgTk0frJ
|