6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/gitlab/experiment/rspec.rb', line 6
def stub_experiments(experiments)
experiments.each do |name, variant|
variant = :control if variant == false
raise ArgumentError, 'variant must be a symbol or false' unless variant.is_a?(Symbol)
klass = Gitlab::Experiment.send(:constantize, name) allow(klass).to receive(:new).and_wrap_original do |new, *args, &block|
new.call(*args).tap do |instance|
allow(instance).to receive(:enabled?).and_return(true)
allow(instance).to receive(:resolve_variant_name).and_return(variant.to_s)
block.call(instance) if block.present?
end
end
end
end
|