gitlab-experiment 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gitlab/experiment.rb +6 -6
- data/lib/gitlab/experiment/{rspec_matchers.rb → rspec.rb} +24 -4
- data/lib/gitlab/experiment/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a26425622afb7aa3f341ff403192963e276876b65902237018f852117168a19a
|
4
|
+
data.tar.gz: 0a5238c73a4b0217810b4f8161df6452b683b21a6573f1b657517302cef9cef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 567ca93e3f931c167bc1766490b07e1535db72e3b5da5986715412746354945ed799dab4c075e91c5015aa922bf5d7e5a82bdc940808aa8100c8897d5ee623b7
|
7
|
+
data.tar.gz: 3f053ed2ad8bdfc2201aacaef9c723332fba260f4f4cb54c65a92539d74ec100297540c34c97579c99723f0d98e98dc57cbe383a0731128d623b0a58b4786d7c
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ When we discuss the behavior of this gem, we'll use terms like experiment, conte
|
|
15
15
|
- `candidate` defines that there's one experimental code path.
|
16
16
|
- `variant(s)` is used when more than one experimental code path exists.
|
17
17
|
|
18
|
-
Candidate and variant are the same concept, but simplify how we speak about experimental paths.<br clear="all">
|
18
|
+
Candidate and variant are the same concept, but simplify how we speak about experimental paths -- this concept is also widely referred to as the "experiment group".<br clear="all">
|
19
19
|
|
20
20
|
[[_TOC_]]
|
21
21
|
|
data/lib/gitlab/experiment.rb
CHANGED
@@ -148,12 +148,6 @@ module Gitlab
|
|
148
148
|
"Experiment;#{id}"
|
149
149
|
end
|
150
150
|
|
151
|
-
def key_for(hash)
|
152
|
-
instance_exec(hash, &Configuration.context_hash_strategy)
|
153
|
-
end
|
154
|
-
|
155
|
-
protected
|
156
|
-
|
157
151
|
def enabled?
|
158
152
|
true
|
159
153
|
end
|
@@ -167,6 +161,12 @@ module Gitlab
|
|
167
161
|
enabled? && !excluded?
|
168
162
|
end
|
169
163
|
|
164
|
+
def key_for(hash)
|
165
|
+
instance_exec(hash, &Configuration.context_hash_strategy)
|
166
|
+
end
|
167
|
+
|
168
|
+
protected
|
169
|
+
|
170
170
|
def run_with_segmenting?
|
171
171
|
!variant_assigned? && enabled? && !excluded?
|
172
172
|
end
|
@@ -2,7 +2,26 @@
|
|
2
2
|
|
3
3
|
module Gitlab
|
4
4
|
class Experiment
|
5
|
-
module
|
5
|
+
module RSpecHelpers
|
6
|
+
def stub_experiments(experiments)
|
7
|
+
experiments.each do |name, variant|
|
8
|
+
variant = :control if variant == false
|
9
|
+
raise ArgumentError, 'variant must be a symbol or false' unless variant.is_a?(Symbol)
|
10
|
+
|
11
|
+
klass = Gitlab::Experiment.send(:constantize, name) # rubocop:disable GitlabSecurity/PublicSend
|
12
|
+
allow(klass).to receive(:new).and_wrap_original do |new, *args, &block|
|
13
|
+
new.call(*args).tap do |instance|
|
14
|
+
allow(instance).to receive(:enabled?).and_return(true)
|
15
|
+
allow(instance).to receive(:resolve_variant_name).and_return(variant.to_s)
|
16
|
+
|
17
|
+
block.call(instance) if block.present?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module RSpecMatchers
|
6
25
|
extend RSpec::Matchers::DSL
|
7
26
|
|
8
27
|
matcher :exclude do |context|
|
@@ -83,9 +102,10 @@ module Gitlab
|
|
83
102
|
end
|
84
103
|
|
85
104
|
RSpec.configure do |config|
|
86
|
-
config.
|
105
|
+
config.include Gitlab::Experiment::RSpecHelpers
|
106
|
+
|
107
|
+
config.include Gitlab::Experiment::RSpecMatchers, :experiment
|
108
|
+
config.define_derived_metadata(file_path: %r{/spec/experiments/}) do |metadata|
|
87
109
|
metadata[:type] = :experiment
|
88
110
|
end
|
89
|
-
|
90
|
-
config.include Gitlab::Experiment::RspecMatchers, :experiment
|
91
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-experiment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- lib/gitlab/experiment/cookies.rb
|
73
73
|
- lib/gitlab/experiment/dsl.rb
|
74
74
|
- lib/gitlab/experiment/engine.rb
|
75
|
-
- lib/gitlab/experiment/
|
75
|
+
- lib/gitlab/experiment/rspec.rb
|
76
76
|
- lib/gitlab/experiment/variant.rb
|
77
77
|
- lib/gitlab/experiment/version.rb
|
78
78
|
homepage: https://gitlab.com/gitlab-org/gitlab-experiment
|