split 3.3.2 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc +1 -1
- data/.github/ISSUE_TEMPLATE/bug_report.md +24 -0
- data/.rspec +1 -0
- data/.rubocop.yml +6 -1155
- data/.rubocop_todo.yml +679 -0
- data/.travis.yml +8 -14
- data/Appraisals +1 -1
- data/CHANGELOG.md +22 -0
- data/CODE_OF_CONDUCT.md +3 -3
- data/Gemfile +1 -0
- data/README.md +15 -13
- data/Rakefile +1 -0
- data/gemfiles/6.0.gemfile +1 -1
- data/lib/split/algorithms/block_randomization.rb +1 -0
- data/lib/split/alternative.rb +3 -3
- data/lib/split/combined_experiments_helper.rb +1 -1
- data/lib/split/configuration.rb +5 -2
- data/lib/split/dashboard.rb +4 -1
- data/lib/split/dashboard/pagination_helpers.rb +2 -3
- data/lib/split/dashboard/views/layout.erb +1 -1
- data/lib/split/engine.rb +6 -4
- data/lib/split/experiment.rb +29 -18
- data/lib/split/goals_collection.rb +1 -0
- data/lib/split/helper.rb +2 -1
- data/lib/split/persistence/dual_adapter.rb +54 -12
- data/lib/split/redis_interface.rb +1 -0
- data/lib/split/trial.rb +1 -1
- data/lib/split/user.rb +5 -1
- data/lib/split/version.rb +2 -2
- data/spec/dashboard/pagination_helpers_spec.rb +3 -1
- data/spec/dashboard_helpers_spec.rb +2 -2
- data/spec/dashboard_spec.rb +37 -16
- data/spec/encapsulated_helper_spec.rb +1 -1
- data/spec/experiment_spec.rb +44 -5
- data/spec/helper_spec.rb +118 -80
- data/spec/persistence/dual_adapter_spec.rb +160 -68
- data/spec/user_spec.rb +11 -0
- data/split.gemspec +1 -2
- metadata +6 -4
@@ -1,102 +1,194 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
3
4
|
|
4
5
|
describe Split::Persistence::DualAdapter do
|
6
|
+
let(:context) { 'some context' }
|
5
7
|
|
6
|
-
let(:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
let(:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
let(:not_selected_adapter){
|
16
|
-
c = Class.new
|
17
|
-
expect(c).not_to receive(:new)
|
18
|
-
c
|
19
|
-
}
|
20
|
-
|
21
|
-
shared_examples_for "forwarding calls" do
|
22
|
-
it "#[]=" do
|
23
|
-
expect(selected_adapter_instance).to receive(:[]=).with('my_key', 'my_value')
|
24
|
-
expect_any_instance_of(not_selected_adapter).not_to receive(:[]=)
|
25
|
-
subject["my_key"] = "my_value"
|
26
|
-
end
|
8
|
+
let(:logged_in_adapter_instance) { double }
|
9
|
+
let(:logged_in_adapter) do
|
10
|
+
Class.new.tap { |c| allow(c).to receive(:new) { logged_in_adapter_instance } }
|
11
|
+
end
|
12
|
+
let(:logged_out_adapter_instance) { double }
|
13
|
+
let(:logged_out_adapter) do
|
14
|
+
Class.new.tap { |c| allow(c).to receive(:new) { logged_out_adapter_instance } }
|
15
|
+
end
|
27
16
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
context 'when fallback_to_logged_out_adapter is false' do
|
18
|
+
context 'when logged in' do
|
19
|
+
subject do
|
20
|
+
described_class.with_config(
|
21
|
+
logged_in: lambda { |context| true },
|
22
|
+
logged_in_adapter: logged_in_adapter,
|
23
|
+
logged_out_adapter: logged_out_adapter,
|
24
|
+
fallback_to_logged_out_adapter: false
|
25
|
+
).new(context)
|
26
|
+
end
|
27
|
+
|
28
|
+
it '#[]=' do
|
29
|
+
expect(logged_in_adapter_instance).to receive(:[]=).with('my_key', 'my_value')
|
30
|
+
expect_any_instance_of(logged_out_adapter).not_to receive(:[]=)
|
31
|
+
subject['my_key'] = 'my_value'
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#[]' do
|
35
|
+
expect(logged_in_adapter_instance).to receive(:[]).with('my_key') { 'my_value' }
|
36
|
+
expect_any_instance_of(logged_out_adapter).not_to receive(:[])
|
37
|
+
expect(subject['my_key']).to eq('my_value')
|
38
|
+
end
|
33
39
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
40
|
+
it '#delete' do
|
41
|
+
expect(logged_in_adapter_instance).to receive(:delete).with('my_key') { 'my_value' }
|
42
|
+
expect_any_instance_of(logged_out_adapter).not_to receive(:delete)
|
43
|
+
expect(subject.delete('my_key')).to eq('my_value')
|
44
|
+
end
|
45
|
+
|
46
|
+
it '#keys' do
|
47
|
+
expect(logged_in_adapter_instance).to receive(:keys) { ['my_value'] }
|
48
|
+
expect_any_instance_of(logged_out_adapter).not_to receive(:keys)
|
49
|
+
expect(subject.keys).to eq(['my_value'])
|
50
|
+
end
|
38
51
|
end
|
39
52
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
53
|
+
context 'when logged out' do
|
54
|
+
subject do
|
55
|
+
described_class.with_config(
|
56
|
+
logged_in: lambda { |context| false },
|
57
|
+
logged_in_adapter: logged_in_adapter,
|
58
|
+
logged_out_adapter: logged_out_adapter,
|
59
|
+
fallback_to_logged_out_adapter: false
|
60
|
+
).new(context)
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#[]=' do
|
64
|
+
expect_any_instance_of(logged_in_adapter).not_to receive(:[]=)
|
65
|
+
expect(logged_out_adapter_instance).to receive(:[]=).with('my_key', 'my_value')
|
66
|
+
subject['my_key'] = 'my_value'
|
67
|
+
end
|
68
|
+
|
69
|
+
it '#[]' do
|
70
|
+
expect_any_instance_of(logged_in_adapter).not_to receive(:[])
|
71
|
+
expect(logged_out_adapter_instance).to receive(:[]).with('my_key') { 'my_value' }
|
72
|
+
expect(subject['my_key']).to eq('my_value')
|
73
|
+
end
|
74
|
+
|
75
|
+
it '#delete' do
|
76
|
+
expect_any_instance_of(logged_in_adapter).not_to receive(:delete)
|
77
|
+
expect(logged_out_adapter_instance).to receive(:delete).with('my_key') { 'my_value' }
|
78
|
+
expect(subject.delete('my_key')).to eq('my_value')
|
79
|
+
end
|
80
|
+
|
81
|
+
it '#keys' do
|
82
|
+
expect_any_instance_of(logged_in_adapter).not_to receive(:keys)
|
83
|
+
expect(logged_out_adapter_instance).to receive(:keys) { ['my_value', 'my_value2'] }
|
84
|
+
expect(subject.keys).to eq(['my_value', 'my_value2'])
|
85
|
+
end
|
44
86
|
end
|
45
87
|
end
|
46
88
|
|
47
|
-
context
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
89
|
+
context 'when fallback_to_logged_out_adapter is true' do
|
90
|
+
context 'when logged in' do
|
91
|
+
subject do
|
92
|
+
described_class.with_config(
|
93
|
+
logged_in: lambda { |context| true },
|
94
|
+
logged_in_adapter: logged_in_adapter,
|
95
|
+
logged_out_adapter: logged_out_adapter,
|
96
|
+
fallback_to_logged_out_adapter: true
|
53
97
|
).new(context)
|
54
|
-
|
98
|
+
end
|
55
99
|
|
56
|
-
|
57
|
-
|
100
|
+
it '#[]=' do
|
101
|
+
expect(logged_in_adapter_instance).to receive(:[]=).with('my_key', 'my_value')
|
102
|
+
expect(logged_out_adapter_instance).to receive(:[]=).with('my_key', 'my_value')
|
103
|
+
expect(logged_out_adapter_instance).to receive(:[]).with('my_key') { nil }
|
104
|
+
subject['my_key'] = 'my_value'
|
105
|
+
end
|
106
|
+
|
107
|
+
it '#[]' do
|
108
|
+
expect(logged_in_adapter_instance).to receive(:[]).with('my_key') { 'my_value' }
|
109
|
+
expect_any_instance_of(logged_out_adapter).not_to receive(:[])
|
110
|
+
expect(subject['my_key']).to eq('my_value')
|
111
|
+
end
|
112
|
+
|
113
|
+
it '#delete' do
|
114
|
+
expect(logged_in_adapter_instance).to receive(:delete).with('my_key') { 'my_value' }
|
115
|
+
expect(logged_out_adapter_instance).to receive(:delete).with('my_key') { 'my_value' }
|
116
|
+
expect(subject.delete('my_key')).to eq('my_value')
|
117
|
+
end
|
118
|
+
|
119
|
+
it '#keys' do
|
120
|
+
expect(logged_in_adapter_instance).to receive(:keys) { ['my_value'] }
|
121
|
+
expect(logged_out_adapter_instance).to receive(:keys) { ['my_value', 'my_value2'] }
|
122
|
+
expect(subject.keys).to eq(['my_value', 'my_value2'])
|
123
|
+
end
|
124
|
+
end
|
58
125
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
126
|
+
context 'when logged out' do
|
127
|
+
subject do
|
128
|
+
described_class.with_config(
|
129
|
+
logged_in: lambda { |context| false },
|
130
|
+
logged_in_adapter: logged_in_adapter,
|
131
|
+
logged_out_adapter: logged_out_adapter,
|
132
|
+
fallback_to_logged_out_adapter: true
|
65
133
|
).new(context)
|
66
|
-
|
134
|
+
end
|
135
|
+
|
136
|
+
it '#[]=' do
|
137
|
+
expect_any_instance_of(logged_in_adapter).not_to receive(:[]=)
|
138
|
+
expect(logged_out_adapter_instance).to receive(:[]=).with('my_key', 'my_value')
|
139
|
+
expect(logged_out_adapter_instance).to receive(:[]).with('my_key') { nil }
|
140
|
+
subject['my_key'] = 'my_value'
|
141
|
+
end
|
142
|
+
|
143
|
+
it '#[]' do
|
144
|
+
expect_any_instance_of(logged_in_adapter).not_to receive(:[])
|
145
|
+
expect(logged_out_adapter_instance).to receive(:[]).with('my_key') { 'my_value' }
|
146
|
+
expect(subject['my_key']).to eq('my_value')
|
147
|
+
end
|
148
|
+
|
149
|
+
it '#delete' do
|
150
|
+
expect(logged_in_adapter_instance).to receive(:delete).with('my_key') { 'my_value' }
|
151
|
+
expect(logged_out_adapter_instance).to receive(:delete).with('my_key') { 'my_value' }
|
152
|
+
expect(subject.delete('my_key')).to eq('my_value')
|
153
|
+
end
|
67
154
|
|
68
|
-
|
155
|
+
it '#keys' do
|
156
|
+
expect(logged_in_adapter_instance).to receive(:keys) { ['my_value'] }
|
157
|
+
expect(logged_out_adapter_instance).to receive(:keys) { ['my_value', 'my_value2'] }
|
158
|
+
expect(subject.keys).to eq(['my_value', 'my_value2'])
|
159
|
+
end
|
160
|
+
end
|
69
161
|
end
|
70
162
|
|
71
|
-
describe
|
72
|
-
before{
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
it "when no logged in adapter" do
|
163
|
+
describe 'when errors in config' do
|
164
|
+
before { described_class.config.clear }
|
165
|
+
let(:some_proc) { ->{} }
|
166
|
+
|
167
|
+
it 'when no logged in adapter' do
|
77
168
|
expect{
|
78
169
|
described_class.with_config(
|
79
170
|
logged_in: some_proc,
|
80
|
-
logged_out_adapter:
|
81
|
-
|
171
|
+
logged_out_adapter: logged_out_adapter
|
172
|
+
).new(context)
|
82
173
|
}.to raise_error(StandardError, /:logged_in_adapter/)
|
83
174
|
end
|
84
|
-
|
175
|
+
|
176
|
+
it 'when no logged out adapter' do
|
85
177
|
expect{
|
86
178
|
described_class.with_config(
|
87
179
|
logged_in: some_proc,
|
88
|
-
logged_in_adapter:
|
89
|
-
|
180
|
+
logged_in_adapter: logged_in_adapter
|
181
|
+
).new(context)
|
90
182
|
}.to raise_error(StandardError, /:logged_out_adapter/)
|
91
183
|
end
|
92
|
-
|
184
|
+
|
185
|
+
it 'when no logged in detector' do
|
93
186
|
expect{
|
94
187
|
described_class.with_config(
|
95
|
-
logged_in_adapter:
|
96
|
-
logged_out_adapter:
|
97
|
-
|
188
|
+
logged_in_adapter: logged_in_adapter,
|
189
|
+
logged_out_adapter: logged_out_adapter
|
190
|
+
).new(context)
|
98
191
|
}.to raise_error(StandardError, /:logged_in$/)
|
99
192
|
end
|
100
193
|
end
|
101
|
-
|
102
194
|
end
|
data/spec/user_spec.rb
CHANGED
@@ -59,6 +59,17 @@ describe Split::User do
|
|
59
59
|
expect(@subject.keys).to include("link_color:finished")
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
context 'when already cleaned up' do
|
64
|
+
before do
|
65
|
+
@subject.cleanup_old_experiments!
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'does not clean up again' do
|
69
|
+
expect(@subject).to_not receive(:keys_without_finished)
|
70
|
+
@subject.cleanup_old_experiments!
|
71
|
+
end
|
72
|
+
end
|
62
73
|
end
|
63
74
|
|
64
75
|
context "instantiated with custom adapter" do
|
data/split.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
$:.push File.expand_path("../lib", __FILE__)
|
3
4
|
require "split/version"
|
4
5
|
|
@@ -24,8 +25,6 @@ Gem::Specification.new do |s|
|
|
24
25
|
s.required_ruby_version = '>= 1.9.3'
|
25
26
|
s.required_rubygems_version = '>= 2.0.0'
|
26
27
|
|
27
|
-
s.rubyforge_project = "split"
|
28
|
-
|
29
28
|
s.files = `git ls-files`.split("\n")
|
30
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
31
30
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: split
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -175,8 +175,11 @@ files:
|
|
175
175
|
- ".csslintrc"
|
176
176
|
- ".eslintignore"
|
177
177
|
- ".eslintrc"
|
178
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
178
179
|
- ".gitignore"
|
180
|
+
- ".rspec"
|
179
181
|
- ".rubocop.yml"
|
182
|
+
- ".rubocop_todo.yml"
|
180
183
|
- ".travis.yml"
|
181
184
|
- Appraisals
|
182
185
|
- CHANGELOG.md
|
@@ -284,8 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
287
|
- !ruby/object:Gem::Version
|
285
288
|
version: 2.0.0
|
286
289
|
requirements: []
|
287
|
-
|
288
|
-
rubygems_version: 2.7.6
|
290
|
+
rubygems_version: 3.0.3
|
289
291
|
signing_key:
|
290
292
|
specification_version: 4
|
291
293
|
summary: Rack based split testing framework
|