Module: Gitlab::Experiment::RSpecMatchers

Extended by:
RSpec::Matchers::DSL
Defined in:
lib/gitlab/experiment/rspec.rb

Instance Method Summary collapse

Instance Method Details

#require_experiment(experiment, matcher, instances_only: true) ⇒ Object

Raises:

  • (ArgumentError)


114
115
116
117
118
119
120
121
122
123
# File 'lib/gitlab/experiment/rspec.rb', line 114

def require_experiment(experiment, matcher, instances_only: true)
  klass = experiment.instance_of?(Class) ? experiment : experiment.class
  raise ArgumentError, "the #{matcher} matcher is limited to experiments" unless klass <= Gitlab::Experiment

  if instances_only && experiment == klass
    raise ArgumentError, "the #{matcher} matcher is limited to experiment instances"
  end

  experiment
end