Module: Overseer::TestingControl::Rails

Defined in:
lib/overseer/testing_control/rails.rb,
lib/overseer/testing_control/rails/engine.rb,
lib/overseer/testing_control/rails/stores.rb,
lib/overseer/testing_control/rails/version.rb,
lib/overseer/testing_control/rails/protocol_v3.rb,
lib/overseer/testing_control/rails/configuration.rb,
lib/overseer/testing_control/rails/request_context.rb,
lib/overseer/testing_control/rails/correlation_middleware.rb,
app/controllers/overseer/testing_control/rails/sinks_controller.rb,
app/controllers/overseer/testing_control/rails/probes_controller.rb,
app/controllers/overseer/testing_control/rails/resets_controller.rb,
app/controllers/overseer/testing_control/rails/states_controller.rb,
app/controllers/overseer/testing_control/rails/application_controller.rb,
app/controllers/overseer/testing_control/rails/capabilities_controller.rb

Defined Under Namespace

Modules: RequestContext Classes: ApplicationController, CapabilitiesController, CaptureError, Configuration, ConfigurationError, CorrelationMiddleware, Engine, IdempotencyConflict, IdempotencyStore, ProbesController, ProtocolFailure, ResetsController, SinkStore, SinksController, StatesController, StoreLimitExceeded

Constant Summary collapse

VERSION =
'0.1.0'
ProtocolV3 =
::Overseer::TestingControl::ProtocolV3

Class Method Summary collapse

Class Method Details

.active? ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
# File 'lib/overseer/testing_control/rails.rb', line 33

def active?
  ::Rails.env.test? && ENV['OVERSEER_TESTING_CONTROL_ENABLED'] == 'true' &&
    configuration.runtime_identity_valid?
rescue StandardError
  false
end

.capture_effect(**attributes) ⇒ Object

Raises:



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/overseer/testing_control/rails.rb', line 40

def capture_effect(**attributes)
  raise CaptureError, 'Testing control is inactive' unless active?

  configuration.finalize!
  context = RequestContext.current
  unless context&.run_id && context.correlation_id
    raise CaptureError, 'A correlated run context is required to capture a fake effect'
  end

  configuration.sink_store.capture(context:, **attributes)
end

.configuration ⇒ Object



20
21
22
# File 'lib/overseer/testing_control/rails.rb', line 20

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



24
25
26
27
28
29
30
31
# File 'lib/overseer/testing_control/rails.rb', line 24

def configure
  unless block_given?
    raise ConfigurationError,
          'Overseer Rails testing-control adapter configuration requires a block'
  end

  yield configuration
end

.reset_configuration! ⇒ Object



52
53
54
# File 'lib/overseer/testing_control/rails.rb', line 52

def reset_configuration!
  @configuration = Configuration.new
end