startback 0.7.0 → 0.7.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa9755df56a5135a9e4bf9be6cd0d8ffb898328c5d19f1039672430eaa50d17d
4
- data.tar.gz: 2386b618ef269a37a216d4d278ab61f23aed0757d316bffbedc5650602a218cb
3
+ metadata.gz: e9d688a604f034506b6c6d0545b282bef855f219150c2c112565c57886447b9a
4
+ data.tar.gz: ac7a20bcc81cf4f14d63cdfa3335a7d3ff73e06534101ee99d579a12f76ea95b
5
5
  SHA512:
6
- metadata.gz: dcc6f5ed9d81c6e33a63a6175a6803fcabd6171afd61985dd86f8866e553770d7b4d969e0ac9867922b1b8af34554ab40b99822348a8bd8d685b5b697f4b0782
7
- data.tar.gz: 9a115ac319cf29fba1c495f26395108d3788de2d4d76370fb9df65dd85afe6598a008b783e69486ab370da36ee9652a5174a716212bdd98f1afed92564801e35
6
+ metadata.gz: 6fa3f5c8b1bc34df9b1072428646825d045666f64422c495fc94888b3d156d05127d3863dc0916cf14b37b1abd35dc926b2828eba6c5e93d42e676a978e2966a
7
+ data.tar.gz: 34754bb9277677691e29f84d6f84822965422414af8a0aad29174969f9cd40aee643bedc119ea28d6773d805f8a5183ab776b9bbdc674bd36d9e0fb4f1d8741c
@@ -1 +1,2 @@
1
1
  require_relative 'audit/trailer'
2
+ require_relative 'audit/prometheus'
@@ -0,0 +1,94 @@
1
+ require 'prometheus/client'
2
+
3
+ module Startback
4
+ module Audit
5
+ #
6
+ # Prometheus exporter abstraction, that can be registered as an around
7
+ # hook on OperationRunner and as a prometheus client on Context instances.
8
+ #
9
+ # The exporter uses the ruby client for prometheus to expose metrics regarding Operation runs.
10
+ #
11
+ # The following metrics are exported:
12
+ #
13
+ # A counter 'operation_errors' (failed runs)
14
+ # A histogram 'operation_calls'
15
+ #
16
+ # All these metrics use the following labels
17
+ # - operation : class name of the operation executed
18
+ #
19
+ # Given that this Exporter is intended to be used as around hook on an
20
+ # `OperationRunner`, operations that fail at construction time will not be
21
+ # exported at all, since they can't be ran in the first place. This may lead
22
+ # to metrics not containing important errors cases if operations check their
23
+ # input at construction time.
24
+ #
25
+ class Prometheus
26
+
27
+ def initialize(options = {})
28
+ @prefix = options[:prefix] || "startback"
29
+ @options = options
30
+ @registry = ::Prometheus::Client.registry
31
+ all_labels = [:operation, :startback_version] + option_labels.keys
32
+ @errors = @registry.counter(
33
+ :"#{prefix}_operation_errors",
34
+ docstring: 'A counter of operation errors',
35
+ labels: all_labels)
36
+ @calls = @registry.histogram(
37
+ :"#{prefix}_operation_calls",
38
+ docstring: 'A histogram of operation latency',
39
+ labels: all_labels)
40
+ end
41
+ attr_reader :registry, :calls, :errors, :options, :prefix
42
+
43
+ def call(runner, op)
44
+ name = op_name(op)
45
+ result = nil
46
+ time = Benchmark.realtime{
47
+ result = yield
48
+ }
49
+ ignore_safely {
50
+ @calls.observe(time, labels: get_labels(name))
51
+ }
52
+ result
53
+ rescue => ex
54
+ ignore_safely {
55
+ @errors.increment(labels: get_labels(name))
56
+ }
57
+ raise
58
+ end
59
+
60
+ protected
61
+
62
+ def ignore_safely
63
+ yield
64
+ rescue => ex
65
+ puts ex.class.to_s + "\n" + ex.message + "\n" + ex.backtrace.join("\n")
66
+ nil
67
+ end
68
+
69
+ def get_labels(op_name)
70
+ option_labels.merge({
71
+ operation: op_name,
72
+ startback_version: version
73
+ })
74
+ end
75
+
76
+ def option_labels
77
+ @options[:labels] || {}
78
+ end
79
+
80
+ def version
81
+ Startback::VERSION
82
+ end
83
+
84
+ def op_name(op)
85
+ case op
86
+ when String then op
87
+ when Class then op.name
88
+ else op.class.name
89
+ end
90
+ end
91
+
92
+ end # class Prometheus
93
+ end # module Audit
94
+ end # module Startback
@@ -99,6 +99,11 @@ module Startback
99
99
  @factored[key] ||= clazz.new(*(args << self))
100
100
  end
101
101
 
102
+ def clean_factored!
103
+ @factored = {}
104
+ end
105
+ private :clean_factored!
106
+
102
107
  def to_h
103
108
  self.class.h_dump!(self)
104
109
  end
@@ -107,6 +112,13 @@ module Startback
107
112
  to_h.to_json(*args, &bl)
108
113
  end
109
114
 
115
+ def dup
116
+ super.tap{|c|
117
+ c.send(:clean_factored!)
118
+ yield(c) if block_given?
119
+ }
120
+ end
121
+
110
122
  end # class Context
111
123
  end # module Startback
112
124
  require_relative 'context/middleware'
@@ -2,7 +2,7 @@ class DateTime
2
2
 
3
3
  # Makes sure that DateTime are exported with ISO8601
4
4
  # conventions when using to_json and to_csv
5
- def to_s
5
+ def to_s(*args)
6
6
  iso8601
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ class Time
2
2
 
3
3
  # Makes sure that Time are exported with ISO8601
4
4
  # conventions when using to_json and to_csv
5
- def to_s
5
+ def to_s(*args)
6
6
  iso8601
7
7
  end
8
8
 
@@ -52,6 +52,14 @@ module Startback
52
52
  super || (world && world.has_key?(name))
53
53
  end
54
54
 
55
+ def with_context(ctx = nil)
56
+ old_world = self.world
57
+ self.world = self.world.merge(context: ctx || old_world.context.dup)
58
+ result = ctx ? yield : yield(self.world.context)
59
+ self.world = old_world
60
+ result
61
+ end
62
+
55
63
  protected
56
64
 
57
65
  def operation_world(op)
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 7
5
- TINY = 0
5
+ TINY = 5
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -17,6 +17,15 @@ module Startback
17
17
  env[Startback::Context::Middleware::RACK_ENV_KEY]
18
18
  end
19
19
 
20
+ def with_context(ctx = nil)
21
+ old_context = self.context
22
+ new_context = ctx || self.context.dup
23
+ env[Startback::Context::Middleware::RACK_ENV_KEY] = new_context
24
+ result = ctx ? yield : yield(new_context)
25
+ env[Startback::Context::Middleware::RACK_ENV_KEY] = old_context
26
+ result
27
+ end
28
+
20
29
  ###
21
30
  ### Facade over third party tools
22
31
  ###
@@ -58,13 +67,17 @@ module Startback
58
67
  [ 204, {}, [] ]
59
68
  end
60
69
 
61
- def serve(entity_description, entity, ct = :json)
70
+ def serve(entity_description, entity, ct = nil)
62
71
  if entity.nil?
63
72
  status 404
64
73
  content_type :json
65
74
  { description: "#{entity_description} not found" }.to_json
66
- else
75
+ elsif entity.respond_to?(:to_dto)
76
+ ct, body = entity.to_dto(context).to(env['HTTP_ACCEPT'], ct)
67
77
  content_type ct
78
+ body
79
+ else
80
+ content_type ct || "application/json"
68
81
  entity.to_json
69
82
  end
70
83
  end
@@ -0,0 +1,16 @@
1
+ require 'prometheus/middleware/exporter'
2
+ module Startback
3
+ module Web
4
+ #
5
+ # Can be used to expose the prometheus metrics inside a Startback
6
+ # application.
7
+ #
8
+ # Example:
9
+ #
10
+ # use Startback::Web::Prometheus
11
+ #
12
+ class Prometheus < Prometheus::Middleware::Exporter
13
+
14
+ end # class Prometheus
15
+ end # module Web
16
+ end # module Startback
@@ -1,98 +1,102 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <testsuite name="rspec" tests="92" skipped="0" failures="0" errors="0" time="6.813605" timestamp="2020-05-15T09:52:24+02:00" hostname="xpertis">
2
+ <testsuite name="rspec" tests="96" skipped="0" failures="0" errors="0" time="3.187118" timestamp="2020-12-11T17:10:42+01:00" hostname="Cassiopeia.local">
3
3
  <properties>
4
- <property name="seed" value="46124"/>
4
+ <property name="seed" value="38436"/>
5
5
  </properties>
6
- <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses to_trail in priority if provided" file="./spec/unit/audit/test_trailer.rb" time="0.000441"></testcase>
7
- <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses input then" file="./spec/unit/audit/test_trailer.rb" time="0.000120"></testcase>
8
- <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses request then" file="./spec/unit/audit/test_trailer.rb" time="0.000119"></testcase>
9
- <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data applies default blacklists for security reasons" file="./spec/unit/audit/test_trailer.rb" time="0.000097"></testcase>
10
- <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data applies default blacklists to data arrays too" file="./spec/unit/audit/test_trailer.rb" time="0.000096"></testcase>
11
- <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses the stop words provided at construction" file="./spec/unit/audit/test_trailer.rb" time="0.000090"></testcase>
12
- <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_context applies default blacklists for security reasons" file="./spec/unit/audit/test_trailer.rb" time="0.000097"></testcase>
13
- <testcase classname="spec.unit.bus.memory.test_async" name="Startback::Bus::Memory allows emiting an receiving" file="./spec/unit/bus/memory/test_async.rb" time="0.000300"></testcase>
14
- <testcase classname="spec.unit.bus.memory.test_async" name="Startback::Bus::Memory allows mixin Symbol vs. String for event type" file="./spec/unit/bus/memory/test_async.rb" time="0.000075"></testcase>
15
- <testcase classname="spec.unit.bus.memory.test_async" name="Startback::Bus::Memory does not raise errors synchronously" file="./spec/unit/bus/memory/test_async.rb" time="0.000891"></testcase>
16
- <testcase classname="spec.unit.bus.memory.test_sync" name="Startback::Bus::Memory allows emiting an receiving" file="./spec/unit/bus/memory/test_sync.rb" time="0.000064"></testcase>
17
- <testcase classname="spec.unit.bus.memory.test_sync" name="Startback::Bus::Memory allows mixin Symbol vs. String for event type" file="./spec/unit/bus/memory/test_sync.rb" time="0.000053"></testcase>
18
- <testcase classname="spec.unit.bus.memory.test_sync" name="Startback::Bus::Memory raises emit errors synchronously" file="./spec/unit/bus/memory/test_sync.rb" time="0.000061"></testcase>
19
- <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache default_ttl has a default ttl of one hour" file="./spec/unit/caching/test_entity_cache.rb" time="0.000045"></testcase>
20
- <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache default_ttl allows overriding it" file="./spec/unit/caching/test_entity_cache.rb" time="0.000038"></testcase>
21
- <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache default_ttl is accessible as default_caching_options on the instance" file="./spec/unit/caching/test_entity_cache.rb" time="0.000046"></testcase>
22
- <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache get yields to load_raw_data only once with the short key" file="./spec/unit/caching/test_entity_cache.rb" time="0.000122"></testcase>
23
- <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache primary_key allows using candidate keys" file="./spec/unit/caching/test_entity_cache.rb" time="0.000088"></testcase>
24
- <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache invalidate strips the key on the store, yielding a cache miss" file="./spec/unit/caching/test_entity_cache.rb" time="0.000136"></testcase>
25
- <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache valid? override yields to load_raw_data only once with the extend key" file="./spec/unit/caching/test_entity_cache.rb" time="0.000153"></testcase>
26
- <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context is a factory for other context-related abstractions" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000385"></testcase>
27
- <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context is takes cares of abstraction arguments" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000059"></testcase>
28
- <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context is caches even in presence ofabstraction arguments" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000050"></testcase>
29
- <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context is distinguishes different abstraction arguments" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000048"></testcase>
30
- <testcase classname="spec.unit.context.test_middleware" name="Startback::Context::Middleware when used without option sets the default context class" file="./spec/unit/context/test_middleware.rb" time="0.002981"></testcase>
31
- <testcase classname="spec.unit.context.test_middleware" name="Startback::Context::Middleware when specifying the context class sets the default context class" file="./spec/unit/context/test_middleware.rb" time="0.000142"></testcase>
32
- <testcase classname="spec.unit.support.hooks.test_after_hook" name="Startback::Support::Hooks after_xxx works as expected" file="./spec/unit/support/hooks/test_after_hook.rb" time="0.000051"></testcase>
33
- <testcase classname="spec.unit.support.hooks.test_after_hook" name="Startback::Support::Hooks after_xxx works as expected on subclass" file="./spec/unit/support/hooks/test_after_hook.rb" time="0.000082"></testcase>
34
- <testcase classname="spec.unit.support.hooks.test_before_hook" name="Startback::Support::Hooks before_xxx works as expected" file="./spec/unit/support/hooks/test_before_hook.rb" time="0.000047"></testcase>
35
- <testcase classname="spec.unit.support.hooks.test_before_hook" name="Startback::Support::Hooks before_xxx works as expected on subclass" file="./spec/unit/support/hooks/test_before_hook.rb" time="0.000046"></testcase>
6
+ <testcase classname="spec.unit.audit.test_prometheus" name="Startback::Audit::Prometheus The ideal case runs the operation" file="./spec/unit/audit/test_prometheus.rb" time="0.004571"></testcase>
7
+ <testcase classname="spec.unit.audit.test_prometheus" name="Startback::Audit::Prometheus The exceptional case let errors bubble up" file="./spec/unit/audit/test_prometheus.rb" time="0.001013"></testcase>
8
+ <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses to_trail in priority if provided" file="./spec/unit/audit/test_trailer.rb" time="0.000181"></testcase>
9
+ <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses input then" file="./spec/unit/audit/test_trailer.rb" time="0.000112"></testcase>
10
+ <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses request then" file="./spec/unit/audit/test_trailer.rb" time="0.000105"></testcase>
11
+ <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data applies default blacklists for security reasons" file="./spec/unit/audit/test_trailer.rb" time="0.000148"></testcase>
12
+ <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data applies default blacklists to data arrays too" file="./spec/unit/audit/test_trailer.rb" time="0.000109"></testcase>
13
+ <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_data uses the stop words provided at construction" file="./spec/unit/audit/test_trailer.rb" time="0.000127"></testcase>
14
+ <testcase classname="spec.unit.audit.test_trailer" name="Startback::Audit::Trailer op_context applies default blacklists for security reasons" file="./spec/unit/audit/test_trailer.rb" time="0.000107"></testcase>
15
+ <testcase classname="spec.unit.bus.memory.test_async" name="Startback::Bus::Memory allows emiting an receiving" file="./spec/unit/bus/memory/test_async.rb" time="0.000419"></testcase>
16
+ <testcase classname="spec.unit.bus.memory.test_async" name="Startback::Bus::Memory allows mixin Symbol vs. String for event type" file="./spec/unit/bus/memory/test_async.rb" time="0.000064"></testcase>
17
+ <testcase classname="spec.unit.bus.memory.test_async" name="Startback::Bus::Memory does not raise errors synchronously" file="./spec/unit/bus/memory/test_async.rb" time="0.000763"></testcase>
18
+ <testcase classname="spec.unit.bus.memory.test_sync" name="Startback::Bus::Memory allows emiting an receiving" file="./spec/unit/bus/memory/test_sync.rb" time="0.000113"></testcase>
19
+ <testcase classname="spec.unit.bus.memory.test_sync" name="Startback::Bus::Memory allows mixin Symbol vs. String for event type" file="./spec/unit/bus/memory/test_sync.rb" time="0.000097"></testcase>
20
+ <testcase classname="spec.unit.bus.memory.test_sync" name="Startback::Bus::Memory raises emit errors synchronously" file="./spec/unit/bus/memory/test_sync.rb" time="0.000072"></testcase>
21
+ <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache default_ttl has a default ttl of one hour" file="./spec/unit/caching/test_entity_cache.rb" time="0.000050"></testcase>
22
+ <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache default_ttl allows overriding it" file="./spec/unit/caching/test_entity_cache.rb" time="0.000040"></testcase>
23
+ <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache default_ttl is accessible as default_caching_options on the instance" file="./spec/unit/caching/test_entity_cache.rb" time="0.000049"></testcase>
24
+ <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache get yields to load_raw_data only once with the short key" file="./spec/unit/caching/test_entity_cache.rb" time="0.000114"></testcase>
25
+ <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache primary_key allows using candidate keys" file="./spec/unit/caching/test_entity_cache.rb" time="0.000089"></testcase>
26
+ <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache invalidate strips the key on the store, yielding a cache miss" file="./spec/unit/caching/test_entity_cache.rb" time="0.000109"></testcase>
27
+ <testcase classname="spec.unit.caching.test_entity_cache" name="Startback::Caching::EntityCache valid? override yields to load_raw_data only once with the extend key" file="./spec/unit/caching/test_entity_cache.rb" time="0.000121"></testcase>
28
+ <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context factor is a factory for other context-related abstractions" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000571"></testcase>
29
+ <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context factor is takes cares of abstraction arguments" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000068"></testcase>
30
+ <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context factor is caches even in presence ofabstraction arguments" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000051"></testcase>
31
+ <testcase classname="spec.unit.context.test_abstraction_factory" name="Startback::Context factor is distinguishes different abstraction arguments" file="./spec/unit/context/test_abstraction_factory.rb" time="0.000052"></testcase>
32
+ <testcase classname="spec.unit.context.test_dup" name="Startback::Context dup yields a dup of the original context" file="./spec/unit/context/test_dup.rb" time="0.000062"></testcase>
33
+ <testcase classname="spec.unit.context.test_dup" name="Startback::Context dup cleans all factored cache" file="./spec/unit/context/test_dup.rb" time="0.000053"></testcase>
34
+ <testcase classname="spec.unit.context.test_h_factory" name="Startback::Context h information contract has a to_json that dumps it" file="./spec/unit/context/test_h_factory.rb" time="0.000047"></testcase>
35
+ <testcase classname="spec.unit.context.test_h_factory" name="Startback::Context h information contract allows installing factories" file="./spec/unit/context/test_h_factory.rb" time="0.001609"></testcase>
36
+ <testcase classname="spec.unit.context.test_h_factory" name="Startback::Context h information contract has a `to_h` information contract that works as expected" file="./spec/unit/context/test_h_factory.rb" time="0.000087"></testcase>
37
+ <testcase classname="spec.unit.context.test_h_factory" name="Startback::Context h information contract has a `h` information contract that works as expected" file="./spec/unit/context/test_h_factory.rb" time="0.000050"></testcase>
38
+ <testcase classname="spec.unit.context.test_middleware" name="Startback::Context::Middleware when used without option sets the default context class" file="./spec/unit/context/test_middleware.rb" time="0.003287"></testcase>
39
+ <testcase classname="spec.unit.context.test_middleware" name="Startback::Context::Middleware when specifying the context class sets the default context class" file="./spec/unit/context/test_middleware.rb" time="0.000177"></testcase>
40
+ <testcase classname="spec.unit.support.hooks.test_after_hook" name="Startback::Support::Hooks after_xxx works as expected" file="./spec/unit/support/hooks/test_after_hook.rb" time="0.000054"></testcase>
41
+ <testcase classname="spec.unit.support.hooks.test_after_hook" name="Startback::Support::Hooks after_xxx works as expected on subclass" file="./spec/unit/support/hooks/test_after_hook.rb" time="0.000050"></testcase>
42
+ <testcase classname="spec.unit.support.hooks.test_before_hook" name="Startback::Support::Hooks before_xxx works as expected" file="./spec/unit/support/hooks/test_before_hook.rb" time="0.000048"></testcase>
43
+ <testcase classname="spec.unit.support.hooks.test_before_hook" name="Startback::Support::Hooks before_xxx works as expected on subclass" file="./spec/unit/support/hooks/test_before_hook.rb" time="0.000073"></testcase>
36
44
  <testcase classname="spec.unit.support.operation_runner.test_around_run" name="Startback::Support::OperationRunner around_run the simplest contract lets run an operation with world bound" file="./spec/unit/support/operation_runner/test_around_run.rb" time="0.000059"></testcase>
37
- <testcase classname="spec.unit.support.operation_runner.test_around_run" name="Startback::Support::OperationRunner around_run the around feature calls the around before the operation itself" file="./spec/unit/support/operation_runner/test_around_run.rb" time="0.000078"></testcase>
38
- <testcase classname="spec.unit.support.operation_runner.test_around_run" name="Startback::Support::OperationRunner around_run the around feature with a class calls the proc with expected parameters" file="./spec/unit/support/operation_runner/test_around_run.rb" time="0.000055"></testcase>
39
- <testcase classname="spec.unit.support.operation_runner.test_around_run" name="Startback::Support::OperationRunner around_run the around feature with a subclass executes all hooks" file="./spec/unit/support/operation_runner/test_around_run.rb" time="0.000079"></testcase>
40
- <testcase classname="spec.unit.support.operation_runner.test_before_after_call" name="Startback::Support::OperationRunner before_call runs before the around hooks" file="./spec/unit/support/operation_runner/test_before_after_call.rb" time="0.000053"></testcase>
41
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness monitor works" file="./spec/unit/support/test_robusteness.rb" time="0.000063"></testcase>
42
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness stop_errors works and logs the error" file="./spec/unit/support/test_robusteness.rb" time="0.000074"></testcase>
43
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness stop_errors returns the result if no error" file="./spec/unit/support/test_robusteness.rb" time="0.000821"></testcase>
44
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness try_max_times fails if n errors are seen" file="./spec/unit/support/test_robusteness.rb" time="1.000773"></testcase>
45
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness try_max_times suceeds if an attemps succeeds" file="./spec/unit/support/test_robusteness.rb" time="1.000698"></testcase>
46
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness try_max_times suceeds if first attemps succeeds" file="./spec/unit/support/test_robusteness.rb" time="0.000442"></testcase>
47
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with full op and no context" file="./spec/unit/support/test_robusteness.rb" time="0.000265"></testcase>
48
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with an string and a method name" file="./spec/unit/support/test_robusteness.rb" time="0.000227"></testcase>
49
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with an string, a method name, and a message" file="./spec/unit/support/test_robusteness.rb" time="0.000320"></testcase>
50
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a string only" file="./spec/unit/support/test_robusteness.rb" time="0.000217"></testcase>
51
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a string and a context with logger" file="./spec/unit/support/test_robusteness.rb" time="0.000245"></testcase>
52
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a string and an extra hash" file="./spec/unit/support/test_robusteness.rb" time="0.000209"></testcase>
53
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a module and method" file="./spec/unit/support/test_robusteness.rb" time="0.000221"></testcase>
54
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a class and method" file="./spec/unit/support/test_robusteness.rb" time="0.000217"></testcase>
55
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with an instance and method" file="./spec/unit/support/test_robusteness.rb" time="0.000218"></testcase>
56
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args when a hash is passed as last arg" file="./spec/unit/support/test_robusteness.rb" time="0.000208"></testcase>
57
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on a logger" file="./spec/unit/support/test_robusteness.rb" time="0.000076"></testcase>
58
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on a Context responding to logger" file="./spec/unit/support/test_robusteness.rb" time="0.000059"></testcase>
59
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on an object having a Context responding to logger" file="./spec/unit/support/test_robusteness.rb" time="0.000058"></testcase>
60
- <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on an object having a Context but no logger" file="./spec/unit/support/test_robusteness.rb" time="0.000046"></testcase>
61
- <testcase classname="spec.unit.test_context" name="Startback::Context has a to_json that dumps it" file="./spec/unit/test_context.rb" time="0.000062"></testcase>
62
- <testcase classname="spec.unit.test_context" name="Startback::Context allows installing factories" file="./spec/unit/test_context.rb" time="0.000091"></testcase>
63
- <testcase classname="spec.unit.test_context" name="Startback::Context has a `to_h` information contract that works as expected" file="./spec/unit/test_context.rb" time="0.000041"></testcase>
64
- <testcase classname="spec.unit.test_context" name="Startback::Context has a `h` information contract that works as expected" file="./spec/unit/test_context.rb" time="0.000056"></testcase>
65
- <testcase classname="spec.unit.test_event" name="Startback::Event presents an ostruct on top of its data" file="./spec/unit/test_event.rb" time="0.000048"></testcase>
66
- <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract has a to_json method that works as expected" file="./spec/unit/test_event.rb" time="0.000052"></testcase>
67
- <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract has a to_json that dumps the context if any" file="./spec/unit/test_event.rb" time="0.000066"></testcase>
68
- <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract has a json class method that works as expected" file="./spec/unit/test_event.rb" time="0.000060"></testcase>
69
- <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract accepts an explicit context in the world" file="./spec/unit/test_event.rb" time="0.000042"></testcase>
70
- <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract accepts an context factory in the world" file="./spec/unit/test_event.rb" time="0.000061"></testcase>
71
- <testcase classname="spec.unit.test_operation" name="Startback::Operation can be bound, which returns a new operation" file="./spec/unit/test_operation.rb" time="0.000041"></testcase>
72
- <testcase classname="spec.unit.test_operation" name="Startback::Operation::MultiOperation lets chain with +" file="./spec/unit/test_operation.rb" time="0.000046"></testcase>
73
- <testcase classname="spec.unit.test_operation" name="Startback::Operation::MultiOperation calls and collects the result on call" file="./spec/unit/test_operation.rb" time="0.000038"></testcase>
74
- <testcase classname="spec.unit.test_operation" name="Startback::Operation::MultiOperation binds every sub operation recursively" file="./spec/unit/test_operation.rb" time="0.000039"></testcase>
75
- <testcase classname="spec.unit.test_support" name="Startback::Support deep_merge works as expected" file="./spec/unit/test_support.rb" time="0.000044"></testcase>
76
- <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when used without options sets the development Cache-Control since this is a test" file="./spec/unit/web/test_auto_caching.rb" time="0.000191"></testcase>
77
- <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when forcing production sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000129"></testcase>
78
- <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when forcing development headers sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000128"></testcase>
79
- <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when setting the Cache-Control header only sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000180"></testcase>
80
- <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when a Cache-Control header is already set by the app sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000133"></testcase>
81
- <testcase classname="spec.unit.web.test_catch_all" name="Startback::Web::CatchAll when used without context returns a 500 with json explanation" file="./spec/unit/web/test_catch_all.rb" time="0.000341"></testcase>
82
- <testcase classname="spec.unit.web.test_catch_all" name="Startback::Web::CatchAll when used with a context providing an error handler returns a 500 with json explanation" file="./spec/unit/web/test_catch_all.rb" time="0.000194"></testcase>
83
- <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when used without options sets the CORS headers to default values" file="./spec/unit/web/test_cors_headers.rb" time="0.000155"></testcase>
84
- <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when used without options strips everything when option" file="./spec/unit/web/test_cors_headers.rb" time="0.000147"></testcase>
85
- <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when used with the :bounce option sets the CORS Origin header to the caller" file="./spec/unit/web/test_cors_headers.rb" time="0.000147"></testcase>
86
- <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when overriding a header sets the CORS Origin header to the caller" file="./spec/unit/web/test_cors_headers.rb" time="0.000145"></testcase>
87
- <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when the app sets specific headers does not override them" file="./spec/unit/web/test_cors_headers.rb" time="0.000143"></testcase>
88
- <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used without a block and no failure returns a 204 when ok" file="./spec/unit/web/test_healthcheck.rb" time="0.000138"></testcase>
89
- <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used without a block a failure raises when ko" file="./spec/unit/web/test_healthcheck.rb" time="0.000112"></testcase>
90
- <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used with a block returning a debug message returns a 200 with plain text message" file="./spec/unit/web/test_healthcheck.rb" time="0.000114"></testcase>
91
- <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used with a block raising an exception re-raises it" file="./spec/unit/web/test_healthcheck.rb" time="0.000120"></testcase>
92
- <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as an app works as expected" file="./spec/unit/web/test_magic_assets.rb" time="1.576671"></testcase>
93
- <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as an app delegates a [] call to sprockets" file="./spec/unit/web/test_magic_assets.rb" time="1.057746"></testcase>
94
- <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as an app returns a 404 on unknown" file="./spec/unit/web/test_magic_assets.rb" time="0.000507"></testcase>
95
- <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as a middleware lets unrelated things pass" file="./spec/unit/web/test_magic_assets.rb" time="0.000259"></testcase>
96
- <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as a middleware serves the assets under the chosen path" file="./spec/unit/web/test_magic_assets.rb" time="1.062687"></testcase>
97
- <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when registering the NgHtmlTransformer works as expected" file="./spec/unit/web/test_magic_assets.rb" time="1.090989"></testcase>
45
+ <testcase classname="spec.unit.support.operation_runner.test_around_run" name="Startback::Support::OperationRunner around_run the around feature calls the around before the operation itself" file="./spec/unit/support/operation_runner/test_around_run.rb" time="0.000063"></testcase>
46
+ <testcase classname="spec.unit.support.operation_runner.test_around_run" name="Startback::Support::OperationRunner around_run the around feature with a class calls the proc with expected parameters" file="./spec/unit/support/operation_runner/test_around_run.rb" time="0.000057"></testcase>
47
+ <testcase classname="spec.unit.support.operation_runner.test_around_run" name="Startback::Support::OperationRunner around_run the around feature with a subclass executes all hooks" file="./spec/unit/support/operation_runner/test_around_run.rb" time="0.000063"></testcase>
48
+ <testcase classname="spec.unit.support.operation_runner.test_before_after_call" name="Startback::Support::OperationRunner before_call runs before the around hooks" file="./spec/unit/support/operation_runner/test_before_after_call.rb" time="0.000054"></testcase>
49
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness monitor works" file="./spec/unit/support/test_robusteness.rb" time="0.000067"></testcase>
50
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness stop_errors works and logs the error" file="./spec/unit/support/test_robusteness.rb" time="0.000079"></testcase>
51
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness stop_errors returns the result if no error" file="./spec/unit/support/test_robusteness.rb" time="0.000060"></testcase>
52
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness try_max_times fails if n errors are seen" file="./spec/unit/support/test_robusteness.rb" time="1.003877"></testcase>
53
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness try_max_times suceeds if an attemps succeeds" file="./spec/unit/support/test_robusteness.rb" time="1.005224"></testcase>
54
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness try_max_times suceeds if first attemps succeeds" file="./spec/unit/support/test_robusteness.rb" time="0.000091"></testcase>
55
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with full op and no context" file="./spec/unit/support/test_robusteness.rb" time="0.000086"></testcase>
56
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with an string and a method name" file="./spec/unit/support/test_robusteness.rb" time="0.000046"></testcase>
57
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with an string, a method name, and a message" file="./spec/unit/support/test_robusteness.rb" time="0.000046"></testcase>
58
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a string only" file="./spec/unit/support/test_robusteness.rb" time="0.000074"></testcase>
59
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a string and a context with logger" file="./spec/unit/support/test_robusteness.rb" time="0.000052"></testcase>
60
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a string and an extra hash" file="./spec/unit/support/test_robusteness.rb" time="0.000045"></testcase>
61
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a module and method" file="./spec/unit/support/test_robusteness.rb" time="0.000069"></testcase>
62
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with a class and method" file="./spec/unit/support/test_robusteness.rb" time="0.000044"></testcase>
63
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args works fine with an instance and method" file="./spec/unit/support/test_robusteness.rb" time="0.000045"></testcase>
64
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness parse_args when a hash is passed as last arg" file="./spec/unit/support/test_robusteness.rb" time="0.000043"></testcase>
65
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on a logger" file="./spec/unit/support/test_robusteness.rb" time="0.000045"></testcase>
66
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on a Context responding to logger" file="./spec/unit/support/test_robusteness.rb" time="0.000043"></testcase>
67
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on an object having a Context responding to logger" file="./spec/unit/support/test_robusteness.rb" time="0.000089"></testcase>
68
+ <testcase classname="spec.unit.support.test_robusteness" name="Startback::Support::Robustness logger_for works on an object having a Context but no logger" file="./spec/unit/support/test_robusteness.rb" time="0.000049"></testcase>
69
+ <testcase classname="spec.unit.test_event" name="Startback::Event presents an ostruct on top of its data" file="./spec/unit/test_event.rb" time="0.000053"></testcase>
70
+ <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract has a to_json method that works as expected" file="./spec/unit/test_event.rb" time="0.000054"></testcase>
71
+ <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract has a to_json that dumps the context if any" file="./spec/unit/test_event.rb" time="0.000054"></testcase>
72
+ <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract has a json class method that works as expected" file="./spec/unit/test_event.rb" time="0.000105"></testcase>
73
+ <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract accepts an explicit context in the world" file="./spec/unit/test_event.rb" time="0.000045"></testcase>
74
+ <testcase classname="spec.unit.test_event" name="Startback::Event the json information contract accepts an context factory in the world" file="./spec/unit/test_event.rb" time="0.000050"></testcase>
75
+ <testcase classname="spec.unit.test_operation" name="Startback::Operation can be bound, which returns a new operation" file="./spec/unit/test_operation.rb" time="0.000068"></testcase>
76
+ <testcase classname="spec.unit.test_operation" name="Startback::Operation::MultiOperation lets chain with +" file="./spec/unit/test_operation.rb" time="0.000049"></testcase>
77
+ <testcase classname="spec.unit.test_operation" name="Startback::Operation::MultiOperation calls and collects the result on call" file="./spec/unit/test_operation.rb" time="0.000043"></testcase>
78
+ <testcase classname="spec.unit.test_operation" name="Startback::Operation::MultiOperation binds every sub operation recursively" file="./spec/unit/test_operation.rb" time="0.000045"></testcase>
79
+ <testcase classname="spec.unit.test_support" name="Startback::Support deep_merge works as expected" file="./spec/unit/test_support.rb" time="0.000047"></testcase>
80
+ <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when used without options sets the development Cache-Control since this is a test" file="./spec/unit/web/test_auto_caching.rb" time="0.000205"></testcase>
81
+ <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when forcing production sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000128"></testcase>
82
+ <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when forcing development headers sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000138"></testcase>
83
+ <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when setting the Cache-Control header only sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000129"></testcase>
84
+ <testcase classname="spec.unit.web.test_auto_caching" name="Startback::Web::AutoCaching when a Cache-Control header is already set by the app sets the production Cache-Control" file="./spec/unit/web/test_auto_caching.rb" time="0.000140"></testcase>
85
+ <testcase classname="spec.unit.web.test_catch_all" name="Startback::Web::CatchAll when used without context returns a 500 with json explanation" file="./spec/unit/web/test_catch_all.rb" time="0.000520"></testcase>
86
+ <testcase classname="spec.unit.web.test_catch_all" name="Startback::Web::CatchAll when used with a context providing an error handler returns a 500 with json explanation" file="./spec/unit/web/test_catch_all.rb" time="0.000225"></testcase>
87
+ <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when used without options sets the CORS headers to default values" file="./spec/unit/web/test_cors_headers.rb" time="0.000149"></testcase>
88
+ <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when used without options strips everything when option" file="./spec/unit/web/test_cors_headers.rb" time="0.000168"></testcase>
89
+ <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when used with the :bounce option sets the CORS Origin header to the caller" file="./spec/unit/web/test_cors_headers.rb" time="0.000154"></testcase>
90
+ <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when overriding a header sets the CORS Origin header to the caller" file="./spec/unit/web/test_cors_headers.rb" time="0.000165"></testcase>
91
+ <testcase classname="spec.unit.web.test_cors_headers" name="Startback::Web::CorsHeaders when the app sets specific headers does not override them" file="./spec/unit/web/test_cors_headers.rb" time="0.000161"></testcase>
92
+ <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used without a block and no failure returns a 204 when ok" file="./spec/unit/web/test_healthcheck.rb" time="0.000163"></testcase>
93
+ <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used without a block a failure raises when ko" file="./spec/unit/web/test_healthcheck.rb" time="0.000144"></testcase>
94
+ <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used with a block returning a debug message returns a 200 with plain text message" file="./spec/unit/web/test_healthcheck.rb" time="0.000117"></testcase>
95
+ <testcase classname="spec.unit.web.test_healthcheck" name="Startback::Web::HealthCheck when used with a block raising an exception re-raises it" file="./spec/unit/web/test_healthcheck.rb" time="0.000110"></testcase>
96
+ <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as an app works as expected" file="./spec/unit/web/test_magic_assets.rb" time="0.380020"></testcase>
97
+ <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as an app delegates a [] call to sprockets" file="./spec/unit/web/test_magic_assets.rb" time="0.257794"></testcase>
98
+ <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as an app returns a 404 on unknown" file="./spec/unit/web/test_magic_assets.rb" time="0.000770"></testcase>
99
+ <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as a middleware lets unrelated things pass" file="./spec/unit/web/test_magic_assets.rb" time="0.000333"></testcase>
100
+ <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when used as a middleware serves the assets under the chosen path" file="./spec/unit/web/test_magic_assets.rb" time="0.256855"></testcase>
101
+ <testcase classname="spec.unit.web.test_magic_assets" name="Startback::Web::MagicAssets when registering the NgHtmlTransformer works as expected" file="./spec/unit/web/test_magic_assets.rb" time="0.252975"></testcase>
98
102
  </testsuite>
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+ require 'startback/audit'
3
+ module Startback
4
+ module Audit
5
+ describe Prometheus do
6
+
7
+ EXPORTER = Prometheus.new({
8
+ prefix: "hello",
9
+ labels: {
10
+ app_version: "1.0"
11
+ }
12
+ })
13
+
14
+ class Runner
15
+ include Startback::Support::OperationRunner
16
+
17
+ class IdealOp < Startback::Operation
18
+ def call
19
+ 42
20
+ end
21
+ end
22
+
23
+ class ExceptionalOp < Startback::Operation
24
+ def call
25
+ raise "Oops"
26
+ end
27
+ end
28
+
29
+ around_run(EXPORTER)
30
+ def test
31
+ run IdealOp.new
32
+ end
33
+ def test_exp
34
+ run ExceptionalOp.new
35
+ end
36
+ end
37
+
38
+ describe 'The ideal case' do
39
+ before do
40
+ expect(EXPORTER.calls).to receive(:observe).with(
41
+ kind_of(Numeric),
42
+ hash_including(labels: {
43
+ operation: "Startback::Audit::Runner::IdealOp",
44
+ startback_version: Startback::VERSION,
45
+ app_version: "1.0"
46
+ }))
47
+ expect(EXPORTER.errors).not_to receive(:increment)
48
+ end
49
+ it 'runs the operation' do
50
+ expect(Runner.new.test).to eql(42)
51
+ end
52
+ end
53
+
54
+ describe 'The exceptional case' do
55
+ before do
56
+ expect(EXPORTER.errors).to receive(:increment).with(
57
+ hash_including(labels: {
58
+ operation: "Startback::Audit::Runner::ExceptionalOp",
59
+ startback_version: Startback::VERSION,
60
+ app_version: "1.0"
61
+ })
62
+ )
63
+ expect(EXPORTER.calls).not_to receive(:observe)
64
+ end
65
+ it 'let errors bubble up' do
66
+ expect { Runner.new.test_exp }.to raise_error(/Oops/)
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Startback
4
- describe Context do
4
+ describe Context, "factor" do
5
5
 
6
6
  let(:context) {
7
7
  Context.new
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ module Startback
4
+ describe Context, "dup" do
5
+
6
+ class Subcontext < Context
7
+ attr_accessor :foo
8
+ end
9
+
10
+ let(:context) {
11
+ Subcontext.new.tap{|s| s.foo = "bar" }
12
+ }
13
+
14
+ class ContextRelatedAbstraction
15
+
16
+ def initialize(context)
17
+ @context = context
18
+ end
19
+ attr_reader :context
20
+
21
+ end
22
+
23
+ it 'yields a dup of the original context' do
24
+ seen = false
25
+ got = context.dup{|x|
26
+ seen = x
27
+ expect(x).not_to be(context)
28
+ }
29
+ expect(seen).to be(got)
30
+ expect(got).to be_a(Subcontext)
31
+ expect(got).not_to be(context)
32
+ expect(got.foo).to eql("bar")
33
+ end
34
+
35
+ it 'cleans all factored cache' do
36
+ cra = context.factor(ContextRelatedAbstraction)
37
+ expect(cra).to be_a(ContextRelatedAbstraction)
38
+ cra2 = context.factor(ContextRelatedAbstraction)
39
+ expect(cra2).to be(cra)
40
+ cra3 = context.dup.factor(ContextRelatedAbstraction)
41
+ expect(cra3).not_to be(cra)
42
+ expect(cra3).not_to be(cra2)
43
+ end
44
+
45
+ end
46
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Startback
4
- describe Context do
4
+ describe Context, "h information contract" do
5
5
 
6
6
  it "has a to_json that dumps it" do
7
7
  expect(Context.new.to_json).to eql("{}")
@@ -16,7 +16,7 @@ module Startback
16
16
  h.merge!("foo" => foo)
17
17
  end
18
18
  end
19
-
19
+
20
20
  class SubContext
21
21
  attr_accessor :bar
22
22
  h_factory do |c,h|
@@ -12,6 +12,7 @@ namespace :test do
12
12
  task :example do
13
13
  Bundler.with_original_env do
14
14
  system("cd example && bundle exec rake")
15
+ abort("Example tests failed") unless $?.exitstatus == 0
15
16
  end
16
17
  end
17
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2020-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -284,7 +284,7 @@ dependencies:
284
284
  requirements:
285
285
  - - ">="
286
286
  - !ruby/object:Gem::Version
287
- version: 0.17.0
287
+ version: 0.17.5
288
288
  - - "<"
289
289
  - !ruby/object:Gem::Version
290
290
  version: 0.18.0
@@ -294,7 +294,7 @@ dependencies:
294
294
  requirements:
295
295
  - - ">="
296
296
  - !ruby/object:Gem::Version
297
- version: 0.17.0
297
+ version: 0.17.5
298
298
  - - "<"
299
299
  - !ruby/object:Gem::Version
300
300
  version: 0.18.0
@@ -372,6 +372,20 @@ dependencies:
372
372
  - - "<"
373
373
  - !ruby/object:Gem::Version
374
374
  version: '2.0'
375
+ - !ruby/object:Gem::Dependency
376
+ name: prometheus-client
377
+ requirement: !ruby/object:Gem::Requirement
378
+ requirements:
379
+ - - ">="
380
+ - !ruby/object:Gem::Version
381
+ version: '2.1'
382
+ type: :runtime
383
+ prerelease: false
384
+ version_requirements: !ruby/object:Gem::Requirement
385
+ requirements:
386
+ - - ">="
387
+ - !ruby/object:Gem::Version
388
+ version: '2.1'
375
389
  description: Yet another ruby backend framework, I'm afraid
376
390
  email: blambeau@gmail.com
377
391
  executables: []
@@ -382,6 +396,7 @@ files:
382
396
  - Rakefile
383
397
  - lib/startback.rb
384
398
  - lib/startback/audit.rb
399
+ - lib/startback/audit/prometheus.rb
385
400
  - lib/startback/audit/trailer.rb
386
401
  - lib/startback/bus.rb
387
402
  - lib/startback/bus/bunny.rb
@@ -419,21 +434,24 @@ files:
419
434
  - lib/startback/web/magic_assets/ng_html_transformer.rb
420
435
  - lib/startback/web/magic_assets/rake_tasks.rb
421
436
  - lib/startback/web/middleware.rb
437
+ - lib/startback/web/prometheus.rb
422
438
  - lib/startback/web/shield.rb
423
439
  - spec/rspec-unit.xml
424
440
  - spec/spec_helper.rb
441
+ - spec/unit/audit/test_prometheus.rb
425
442
  - spec/unit/audit/test_trailer.rb
426
443
  - spec/unit/bus/memory/test_async.rb
427
444
  - spec/unit/bus/memory/test_sync.rb
428
445
  - spec/unit/caching/test_entity_cache.rb
429
446
  - spec/unit/context/test_abstraction_factory.rb
447
+ - spec/unit/context/test_dup.rb
448
+ - spec/unit/context/test_h_factory.rb
430
449
  - spec/unit/context/test_middleware.rb
431
450
  - spec/unit/support/hooks/test_after_hook.rb
432
451
  - spec/unit/support/hooks/test_before_hook.rb
433
452
  - spec/unit/support/operation_runner/test_around_run.rb
434
453
  - spec/unit/support/operation_runner/test_before_after_call.rb
435
454
  - spec/unit/support/test_robusteness.rb
436
- - spec/unit/test_context.rb
437
455
  - spec/unit/test_event.rb
438
456
  - spec/unit/test_operation.rb
439
457
  - spec/unit/test_support.rb
@@ -450,7 +468,7 @@ homepage: http://www.enspirit.be
450
468
  licenses:
451
469
  - MIT
452
470
  metadata: {}
453
- post_install_message:
471
+ post_install_message:
454
472
  rdoc_options: []
455
473
  require_paths:
456
474
  - lib
@@ -465,8 +483,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
465
483
  - !ruby/object:Gem::Version
466
484
  version: '0'
467
485
  requirements: []
468
- rubygems_version: 3.1.2
469
- signing_key:
486
+ rubygems_version: 3.1.4
487
+ signing_key:
470
488
  specification_version: 4
471
489
  summary: Got Your Ruby Back
472
490
  test_files: []