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)


127
128
129
130
131
132
133
134
135
136
# File 'lib/gitlab/experiment/rspec.rb', line 127

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