split 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +6 -3
- data/.rubocop.yml +2 -5
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +2 -1
- data/README.md +4 -2
- data/Rakefile +4 -5
- data/gemfiles/5.2.gemfile +1 -3
- data/gemfiles/6.0.gemfile +1 -3
- data/gemfiles/6.1.gemfile +1 -3
- data/gemfiles/7.0.gemfile +2 -3
- data/lib/split/algorithms/block_randomization.rb +5 -6
- data/lib/split/algorithms/whiplash.rb +16 -18
- data/lib/split/algorithms.rb +22 -0
- data/lib/split/alternative.rb +21 -22
- data/lib/split/cache.rb +0 -1
- data/lib/split/combined_experiments_helper.rb +4 -4
- data/lib/split/configuration.rb +83 -84
- data/lib/split/dashboard/helpers.rb +6 -7
- data/lib/split/dashboard/pagination_helpers.rb +53 -54
- data/lib/split/dashboard/public/style.css +5 -2
- data/lib/split/dashboard/views/index.erb +19 -4
- data/lib/split/dashboard.rb +29 -23
- data/lib/split/encapsulated_helper.rb +4 -6
- data/lib/split/experiment.rb +84 -88
- data/lib/split/experiment_catalog.rb +6 -5
- data/lib/split/extensions/string.rb +1 -1
- data/lib/split/goals_collection.rb +8 -10
- data/lib/split/helper.rb +19 -19
- data/lib/split/metric.rb +4 -5
- data/lib/split/persistence/cookie_adapter.rb +44 -47
- data/lib/split/persistence/dual_adapter.rb +7 -8
- data/lib/split/persistence/redis_adapter.rb +2 -3
- data/lib/split/persistence/session_adapter.rb +0 -2
- data/lib/split/persistence.rb +4 -4
- data/lib/split/redis_interface.rb +1 -2
- data/lib/split/trial.rb +23 -24
- data/lib/split/user.rb +12 -13
- data/lib/split/version.rb +1 -1
- data/lib/split/zscore.rb +1 -3
- data/lib/split.rb +26 -25
- data/spec/algorithms/block_randomization_spec.rb +6 -5
- data/spec/algorithms/weighted_sample_spec.rb +6 -5
- data/spec/algorithms/whiplash_spec.rb +4 -5
- data/spec/alternative_spec.rb +35 -36
- data/spec/cache_spec.rb +15 -19
- data/spec/combined_experiments_helper_spec.rb +18 -17
- data/spec/configuration_spec.rb +32 -38
- data/spec/dashboard/pagination_helpers_spec.rb +69 -67
- data/spec/dashboard/paginator_spec.rb +10 -9
- data/spec/dashboard_helpers_spec.rb +19 -18
- data/spec/dashboard_spec.rb +67 -35
- data/spec/encapsulated_helper_spec.rb +12 -14
- data/spec/experiment_catalog_spec.rb +14 -13
- data/spec/experiment_spec.rb +121 -123
- data/spec/goals_collection_spec.rb +17 -15
- data/spec/helper_spec.rb +379 -382
- data/spec/metric_spec.rb +14 -14
- data/spec/persistence/cookie_adapter_spec.rb +23 -8
- data/spec/persistence/dual_adapter_spec.rb +71 -71
- data/spec/persistence/redis_adapter_spec.rb +25 -26
- data/spec/persistence/session_adapter_spec.rb +2 -3
- data/spec/persistence_spec.rb +1 -2
- data/spec/redis_interface_spec.rb +16 -14
- data/spec/spec_helper.rb +15 -13
- data/spec/split_spec.rb +11 -11
- data/spec/support/cookies_mock.rb +1 -2
- data/spec/trial_spec.rb +61 -60
- data/spec/user_spec.rb +36 -36
- data/split.gemspec +20 -20
- metadata +7 -10
- data/.rubocop_todo.yml +0 -226
- data/Appraisals +0 -19
- data/gemfiles/5.0.gemfile +0 -9
- data/gemfiles/5.1.gemfile +0 -9
@@ -1,41 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
require "split/goals_collection"
|
5
|
+
require "time"
|
4
6
|
|
5
7
|
describe Split::GoalsCollection do
|
6
|
-
let(:experiment_name) {
|
8
|
+
let(:experiment_name) { "experiment_name" }
|
7
9
|
|
8
|
-
describe
|
10
|
+
describe "initialization" do
|
9
11
|
let(:goals_collection) {
|
10
|
-
Split::GoalsCollection.new(
|
12
|
+
Split::GoalsCollection.new("experiment_name", ["goal1", "goal2"])
|
11
13
|
}
|
12
14
|
|
13
15
|
it "should have an experiment_name" do
|
14
16
|
expect(goals_collection.instance_variable_get(:@experiment_name)).
|
15
|
-
to eq(
|
17
|
+
to eq("experiment_name")
|
16
18
|
end
|
17
19
|
|
18
20
|
it "should have a list of goals" do
|
19
21
|
expect(goals_collection.instance_variable_get(:@goals)).
|
20
|
-
to eq([
|
22
|
+
to eq(["goal1", "goal2"])
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
describe "#validate!" do
|
25
27
|
it "should't raise ArgumentError if @goals is nil?" do
|
26
|
-
goals_collection = Split::GoalsCollection.new(
|
28
|
+
goals_collection = Split::GoalsCollection.new("experiment_name")
|
27
29
|
expect { goals_collection.validate! }.not_to raise_error
|
28
30
|
end
|
29
31
|
|
30
32
|
it "should raise ArgumentError if @goals is not an Array" do
|
31
33
|
goals_collection = Split::GoalsCollection.
|
32
|
-
new(
|
34
|
+
new("experiment_name", "not an array")
|
33
35
|
expect { goals_collection.validate! }.to raise_error(ArgumentError)
|
34
36
|
end
|
35
37
|
|
36
38
|
it "should't raise ArgumentError if @goals is an array" do
|
37
39
|
goals_collection = Split::GoalsCollection.
|
38
|
-
new(
|
40
|
+
new("experiment_name", ["an array"])
|
39
41
|
expect { goals_collection.validate! }.not_to raise_error
|
40
42
|
end
|
41
43
|
end
|
@@ -44,7 +46,7 @@ describe Split::GoalsCollection do
|
|
44
46
|
let(:goals_key) { "#{experiment_name}:goals" }
|
45
47
|
|
46
48
|
it "should delete goals from redis" do
|
47
|
-
goals_collection = Split::GoalsCollection.new(experiment_name, [
|
49
|
+
goals_collection = Split::GoalsCollection.new(experiment_name, ["goal1"])
|
48
50
|
goals_collection.save
|
49
51
|
|
50
52
|
goals_collection.delete
|
@@ -63,7 +65,7 @@ describe Split::GoalsCollection do
|
|
63
65
|
end
|
64
66
|
|
65
67
|
it "should save goals to redis if @goals is valid" do
|
66
|
-
goals = [
|
68
|
+
goals = ["valid goal 1", "valid goal 2"]
|
67
69
|
collection = Split::GoalsCollection.new(experiment_name, goals)
|
68
70
|
collection.save
|
69
71
|
|
@@ -72,9 +74,9 @@ describe Split::GoalsCollection do
|
|
72
74
|
|
73
75
|
it "should return @goals if @goals is valid" do
|
74
76
|
goals_collection = Split::GoalsCollection.
|
75
|
-
new(experiment_name, [
|
77
|
+
new(experiment_name, ["valid goal"])
|
76
78
|
|
77
|
-
expect(goals_collection.save).to eq([
|
79
|
+
expect(goals_collection.save).to eq(["valid goal"])
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|