Module: Gitlab::Experiment::RSpecMocks

Defined in:
lib/gitlab/experiment/rspec.rb

Defined Under Namespace

Modules: MethodDouble

Class Method Summary collapse

Class Method Details

.bind_gitlab_experiment_receiver(method) ⇒ Object



22
23
24
# File 'lib/gitlab/experiment/rspec.rb', line 22

def self.bind_gitlab_experiment_receiver(method)
  method.unbind.bind(@__gitlab_experiment_receivers[method].pop)
end

.track_gitlab_experiment_receiver(method, receiver) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/gitlab/experiment/rspec.rb', line 14

def self.track_gitlab_experiment_receiver(method, receiver)
  # Leverage the `>=` method on Gitlab::Experiment to determine if the receiver is an experiment, not the other
  # way round -- `receiver.<=` could be mocked and we want to be extra careful.
  (@__gitlab_experiment_receivers[method] ||= []) << receiver if Gitlab::Experiment >= receiver
rescue StandardError # again, let's just be extra careful
  false
end