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: fdad0623324b5fb131122851c3cfb7862cc7c69e5ed6d545b49cd4ffb953ff14
4
- data.tar.gz: 54f7c93ae468fa246e118bdc47cefdf4a4db0ac31b4e1754bc99dd72364997bc
3
+ metadata.gz: ed82ce916f1e735296247aa088af8dc8f737824129ca9c45eabd9bd691f073be
4
+ data.tar.gz: dca8a2b9ca82e6bdc2ac9af520fd61f4b31f7a8d59bb03224b0aac966960ba0f
5
5
  SHA512:
6
- metadata.gz: c05415a4d45673ccf2857b1747896c8581c5c726d54ebb0d7dc59788bcbbef4791762b2099daa7e9b09b45e523cc709260e0884b52aca6d62b5c3a7375056fc2
7
- data.tar.gz: 36907744056f4c477ff9b8fdc43f69a2560d757d70f9b43d3fcef7bf3493a2fef11084b069d84662ce8633c5c12c45d70cc12d177757f43989121be60b1deb32
6
+ metadata.gz: 12651f784af98ac806f5a266d921d788f4b45b33ce159592f0ec4b6a0ad6cb850c8341b50236ae6d25348fdb070dcc3f415f311d07e54dd7cdf2c7a92b96c48b
7
+ data.tar.gz: a5357b66bf2cef3ecf4cd39d47272cfeabfedeea56fd72659ae8ca084895cdd9c0576521979d91ae1fd800cbce5e1bbbcd15cc0785d16ec3a938054c7838bbab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.4.0
2
+
3
+ * Added support for configurable rendering (#6)
4
+
1
5
  ### 0.3.0
2
6
 
3
7
  * Removed CI support for Ruby 2.3 (it never worked before)
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 as an API v1 representation
44
- render plain: entity.to_json, content_type: 'application/json'
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module FactoryBot
4
4
  module Instrumentation
5
- VERSION = '0.3.0'.freeze
5
+ VERSION = '0.4.0'.freeze
6
6
  end
7
7
  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.3.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-07-15 00:00:00.000000000 Z
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.4
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