factory_bot_instrumentation 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed82ce916f1e735296247aa088af8dc8f737824129ca9c45eabd9bd691f073be
|
4
|
+
data.tar.gz: dca8a2b9ca82e6bdc2ac9af520fd61f4b31f7a8d59bb03224b0aac966960ba0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12651f784af98ac806f5a266d921d788f4b45b33ce159592f0ec4b6a0ad6cb850c8341b50236ae6d25348fdb070dcc3f415f311d07e54dd7cdf2c7a92b96c48b
|
7
|
+
data.tar.gz: a5357b66bf2cef3ecf4cd39d47272cfeabfedeea56fd72659ae8ca084895cdd9c0576521979d91ae1fd800cbce5e1bbbcd15cc0785d16ec3a938054c7838bbab
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -301,6 +301,12 @@ FactoryBot::Instrumentation.configure do |conf|
|
|
301
301
|
# The instrumentation configuration file path we should use,
|
302
302
|
# defaults to config/instrumentation.yml
|
303
303
|
conf.config_file = 'config/scenarios.yml'
|
304
|
+
# By default we use the Rails default JSON rendering mechanism, but
|
305
|
+
# you can configure your own logic here (eg. a custom representer)
|
306
|
+
conf.render_entity = proc do |controller, entity|
|
307
|
+
controller.render plain: entity.to_json,
|
308
|
+
content_type: 'application/json'
|
309
|
+
end
|
304
310
|
end
|
305
311
|
```
|
306
312
|
|
@@ -40,8 +40,8 @@ module FactoryBot::Instrumentation
|
|
40
40
|
FactoryBot.reload
|
41
41
|
# Call the factory construction with the user given parameters
|
42
42
|
entity = FactoryBot.create(*factory_params)
|
43
|
-
# Render the resulting entity
|
44
|
-
|
43
|
+
# Render the resulting entity with the configured rendering block
|
44
|
+
FactoryBot::Instrumentation.configuration.render_entity.call(self, entity)
|
45
45
|
rescue StandardError => err
|
46
46
|
# Log for local factory debugging and re-raise for canary onwards
|
47
47
|
Rails.logger.error("#{err}\n#{err.backtrace.join("\n")}")
|
@@ -15,6 +15,15 @@ module FactoryBot
|
|
15
15
|
# You can set a fixed application name here,
|
16
16
|
# defaults to your Rails application name in a titlized version
|
17
17
|
config_accessor(:application_name) { nil }
|
18
|
+
|
19
|
+
# By default we use the Rails default JSON rendering mechanism, but
|
20
|
+
# you can configure your own logic here
|
21
|
+
config_accessor(:render_entity) do
|
22
|
+
proc do |controller, entity|
|
23
|
+
controller.render plain: entity.to_json,
|
24
|
+
content_type: 'application/json'
|
25
|
+
end
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot_instrumentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hermann Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
|
-
rubygems_version: 3.0.
|
206
|
+
rubygems_version: 3.0.6
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: Allow your testers to generate test data on demand
|