module Experimental::Test
Test
helpers for applications that use Experimental
.
For popular test frameworks, simply require the appropriate experimental/test/*.rb file. If those doesn’t cover you, check one of those to see how to hook up your favorite framework.
Public Class Methods
initialize()
click to toggle source
Call this once to initialize Experimental
for your test suite.
Calling it again isn’t harmful, just unnecessary.
# File lib/experimental/test.rb, line 11 def self.initialize return if @initialized @initial_source = Experimental.source Experimental.source = Experimental::Source::Configuration.new @initialized = true end
setup()
click to toggle source
Call this before each test. It provides a deterministic default: all subjects are out of all experiments. Opt subjects into experiments using set_experimental_bucket
.
# File lib/experimental/test.rb, line 21 def self.setup Experimental.overrides.reset Experimental.overrides.set_default(nil) end
teardown()
click to toggle source
# File lib/experimental/test.rb, line 26 def self.teardown Experimental.source = @initial_source @initialized = false end
Public Instance Methods
set_experimental_bucket(subject, experiment_name, bucket)
click to toggle source
Force the given subject into the given bucket
of the given experiment
.
If bucket
is nil, exclude the user from the experiment.
# File lib/experimental/test.rb, line 34 def set_experimental_bucket(subject, experiment_name, bucket) Experimental.overrides[subject, experiment_name] = bucket end