factory_bot_instrumentation 0.5.1 → 0.6.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: 54a54c125597690d91ed7fd019112d3645cce6dfe056b6ae6246ad57bddc28ef
4
- data.tar.gz: 06d728a403143c456beba2da6cf19d10cc4b4271bb9c1e3171cd8e94b2684994
3
+ metadata.gz: ff6458a1179520c115511b80ad9bdcb335fb652a04c647a12e7515a678440942
4
+ data.tar.gz: dce3493555ed93a948fea4b4d79b0dbb8c9d1984439706d4b0d1b400a75748fb
5
5
  SHA512:
6
- metadata.gz: aa3ca826e2d9a6ab252d5e81399946e3f620f8342663fc139362a9f7d19945fb5b12e78512631aac222fda6496cd506bae35142f7704f1d45b3cba319cbe6c52
7
- data.tar.gz: e481b8193bb3529e88ee6725e3fbcf6b85058984705b2a378032862d5d3e2dad95e53ad473dfb606e5344f746d59224a223f5d376bf8f71a1bc54ce5f677a217
6
+ metadata.gz: 24a2ffa2f0c9092222f13826ec2e5232db505fcaddb8df33ae0eed39494ac8a36248f3c3cd39582fc88b6447401dbdd7850a08b6ed045091321f543d67eacc89
7
+ data.tar.gz: ab32dc405102f93ea3b6dfc409c292600b8bfdac8839bc4cabe949fe8168729d8f8a6b435798c3703bfcd1eba9853870344e2875f9ebef77d1182bea81c71276
@@ -1,3 +1,8 @@
1
+ ### 0.6.0
2
+
3
+ * Added support for custom error handling and improved the default error
4
+ handling on FactoryBot usage (#9)
5
+
1
6
  ### 0.5.1
2
7
 
3
8
  * Corrected a bug on the scenario description update (#8)
data/README.md CHANGED
@@ -316,6 +316,18 @@ FactoryBot::Instrumentation.configure do |conf|
316
316
  controller.render plain: entity.to_json,
317
317
  content_type: 'application/json'
318
318
  end
319
+ # By default we assemble a JSON response on errors which may be
320
+ # helpful for debugging, but you can configure your own logic here
321
+ conf.render_error = proc do |controller, error|
322
+ app_name = FactoryBot::Instrumentation.configuration.application_name
323
+ controller.render status: :internal_server_error,
324
+ content_type: 'application/json',
325
+ plain: {
326
+ application: app_name,
327
+ error: error.message,
328
+ backtrace: error.backtrace.join("\n")
329
+ }.to_json
330
+ end
319
331
  # By default we do not perform any custom +before_action+ filters on the
320
332
  # instrumentation controllers, with this option you can implement your
321
333
  # custom logic like authentication
@@ -43,9 +43,8 @@ module FactoryBot::Instrumentation
43
43
  # Render the resulting entity with the configured rendering block
44
44
  FactoryBot::Instrumentation.configuration.render_entity.call(self, entity)
45
45
  rescue StandardError => err
46
- # Log for local factory debugging and re-raise for canary onwards
47
- Rails.logger.error("#{err}\n#{err.backtrace.join("\n")}")
48
- raise err
46
+ # Handle any error gracefully with the configured error handler
47
+ FactoryBot::Instrumentation.configuration.render_error.call(self, err)
49
48
  end
50
49
 
51
50
  private
@@ -25,6 +25,21 @@ module FactoryBot
25
25
  end
26
26
  end
27
27
 
28
+ # By default we assemble a JSON response on errors which may be
29
+ # helpful for debugging, but you can configure your own logic here
30
+ config_accessor(:render_error) do
31
+ proc do |controller, error|
32
+ app_name = FactoryBot::Instrumentation.configuration.application_name
33
+ controller.render status: :internal_server_error,
34
+ content_type: 'application/json',
35
+ plain: {
36
+ application: app_name,
37
+ error: error.message,
38
+ backtrace: error.backtrace.join("\n")
39
+ }.to_json
40
+ end
41
+ end
42
+
28
43
  # By default we do not perform any custom +before_action+ filters on the
29
44
  # instrumentation controllers, with this option you can implement your
30
45
  # custom logic like authentication
@@ -2,6 +2,6 @@
2
2
 
3
3
  module FactoryBot
4
4
  module Instrumentation
5
- VERSION = '0.5.1'.freeze
5
+ VERSION = '0.6.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.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -188,7 +188,7 @@ files:
188
188
  homepage: https://github.com/hausgold/factory_bot_instrumentation
189
189
  licenses: []
190
190
  metadata: {}
191
- post_install_message:
191
+ post_install_message:
192
192
  rdoc_options: []
193
193
  require_paths:
194
194
  - lib
@@ -203,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  - !ruby/object:Gem::Version
204
204
  version: '0'
205
205
  requirements: []
206
- rubygems_version: 3.1.2
207
- signing_key:
206
+ rubygems_version: 3.1.4
207
+ signing_key:
208
208
  specification_version: 4
209
209
  summary: Allow your testers to generate test data on demand
210
210
  test_files: []