Module: Experimental::Test

Included in:
RSpec, Unit
Defined in:
lib/experimental/test.rb,
lib/experimental/test/unit.rb,
lib/experimental/test/rspec.rb

Overview

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.

Defined Under Namespace

Modules: RSpec, Unit

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initializeObject

Call this once to initialize Experimental for your test suite.

Calling it again isn’t harmful, just unnecessary.



11
12
13
14
15
# File 'lib/experimental/test.rb', line 11

def self.initialize
  return if @initialized
  Experimental.source = Experimental::Source::Configuration.new
  @initialized = true
end

.setupObject

Call this before each test.



18
19
20
# File 'lib/experimental/test.rb', line 18

def self.setup
  Experimental.overrides.reset
end

Instance Method Details

#set_experimental_bucket(subject, experiment_name, bucket) ⇒ Object

Force the given subject into the given bucket of the given experiment.

If bucket is nil, exclude the user from the experiment.



25
26
27
# File 'lib/experimental/test.rb', line 25

def set_experimental_bucket(subject, experiment_name, bucket)
  Experimental.overrides[subject, experiment_name] = bucket
end