split 4.0.1 → 4.0.3
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 +8 -3
- data/.rubocop.yml +2 -5
- data/CHANGELOG.md +38 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -1
- data/README.md +11 -3
- 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 +1 -3
- data/lib/split/algorithms/block_randomization.rb +5 -6
- data/lib/split/algorithms/whiplash.rb +16 -18
- data/lib/split/algorithms.rb +14 -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/_experiment.erb +2 -1
- 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 +93 -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 +20 -20
- 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 +3 -4
- data/lib/split/persistence/session_adapter.rb +0 -2
- data/lib/split/persistence.rb +4 -4
- data/lib/split/redis_interface.rb +7 -1
- 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 +79 -35
- data/spec/encapsulated_helper_spec.rb +12 -14
- data/spec/experiment_catalog_spec.rb +14 -13
- data/spec/experiment_spec.rb +132 -123
- data/spec/goals_collection_spec.rb +17 -15
- data/spec/helper_spec.rb +415 -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 +28 -29
- data/spec/persistence/session_adapter_spec.rb +2 -3
- data/spec/persistence_spec.rb +1 -2
- data/spec/redis_interface_spec.rb +26 -14
- data/spec/spec_helper.rb +16 -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 +21 -20
- metadata +25 -14
- 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,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Split::EncapsulatedHelper do
|
5
6
|
include Split::EncapsulatedHelper
|
6
7
|
|
7
|
-
|
8
8
|
def params
|
9
|
-
raise NoMethodError,
|
9
|
+
raise NoMethodError, "This method is not really defined"
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "ab_test" do
|
@@ -16,37 +16,35 @@ describe Split::EncapsulatedHelper do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should not raise an error when params raises an error" do
|
19
|
-
expect{ params }.to raise_error(NoMethodError)
|
20
|
-
expect
|
19
|
+
expect { params }.to raise_error(NoMethodError)
|
20
|
+
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
|
21
21
|
end
|
22
22
|
|
23
23
|
it "calls the block with selected alternative" do
|
24
|
-
expect{|block| ab_test(
|
24
|
+
expect { |block| ab_test("link_color", "red", "red", &block) }.to yield_with_args("red", {})
|
25
25
|
end
|
26
26
|
|
27
27
|
context "inside a view" do
|
28
|
-
|
29
28
|
it "works inside ERB" do
|
30
|
-
require
|
31
|
-
template = ERB.new(<<-ERB.split(/\s+/s).map(&:strip).join(
|
29
|
+
require "erb"
|
30
|
+
template = ERB.new(<<-ERB.split(/\s+/s).map(&:strip).join(" "), nil, "%")
|
32
31
|
foo <% ab_test(:foo, '1', '2') do |alt, meta| %>
|
33
32
|
static <%= alt %>
|
34
33
|
<% end %>
|
35
34
|
ERB
|
36
35
|
expect(template.result(binding)).to match(/foo static \d/)
|
37
36
|
end
|
38
|
-
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
40
|
describe "context" do
|
43
|
-
it
|
44
|
-
ctx = Class.new{
|
41
|
+
it "is passed in shim" do
|
42
|
+
ctx = Class.new {
|
45
43
|
include Split::EncapsulatedHelper
|
46
44
|
public :session
|
47
45
|
}.new
|
48
|
-
expect(ctx).to receive(:session){{}}
|
49
|
-
expect{ ctx.ab_test(
|
46
|
+
expect(ctx).to receive(:session) { {} }
|
47
|
+
expect { ctx.ab_test("link_color", "blue", "red") }.not_to raise_error
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
@@ -1,53 +1,54 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "spec_helper"
|
3
4
|
|
4
5
|
describe Split::ExperimentCatalog do
|
5
6
|
subject { Split::ExperimentCatalog }
|
6
7
|
|
7
8
|
describe ".find_or_create" do
|
8
9
|
it "should not raise an error when passed strings for alternatives" do
|
9
|
-
expect { subject.find_or_create(
|
10
|
+
expect { subject.find_or_create("xyz", "1", "2", "3") }.not_to raise_error
|
10
11
|
end
|
11
12
|
|
12
13
|
it "should not raise an error when passed an array for alternatives" do
|
13
|
-
expect { subject.find_or_create(
|
14
|
+
expect { subject.find_or_create("xyz", ["1", "2", "3"]) }.not_to raise_error
|
14
15
|
end
|
15
16
|
|
16
17
|
it "should raise the appropriate error when passed integers for alternatives" do
|
17
|
-
expect { subject.find_or_create(
|
18
|
+
expect { subject.find_or_create("xyz", 1, 2, 3) }.to raise_error(ArgumentError)
|
18
19
|
end
|
19
20
|
|
20
21
|
it "should raise the appropriate error when passed symbols for alternatives" do
|
21
|
-
expect { subject.find_or_create(
|
22
|
+
expect { subject.find_or_create("xyz", :a, :b, :c) }.to raise_error(ArgumentError)
|
22
23
|
end
|
23
24
|
|
24
25
|
it "should not raise error when passed an array for goals" do
|
25
|
-
expect { subject.find_or_create({
|
26
|
+
expect { subject.find_or_create({ "link_color" => ["purchase", "refund"] }, "blue", "red") }
|
26
27
|
.not_to raise_error
|
27
28
|
end
|
28
29
|
|
29
30
|
it "should not raise error when passed just one goal" do
|
30
|
-
expect { subject.find_or_create({
|
31
|
+
expect { subject.find_or_create({ "link_color" => "purchase" }, "blue", "red") }
|
31
32
|
.not_to raise_error
|
32
33
|
end
|
33
34
|
|
34
35
|
it "constructs a new experiment" do
|
35
|
-
expect(subject.find_or_create(
|
36
|
+
expect(subject.find_or_create("my_exp", "control me").control.to_s).to eq("control me")
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
describe
|
40
|
+
describe ".find" do
|
40
41
|
it "should return an existing experiment" do
|
41
|
-
experiment = Split::Experiment.new(
|
42
|
+
experiment = Split::Experiment.new("basket_text", alternatives: ["blue", "red", "green"])
|
42
43
|
experiment.save
|
43
44
|
|
44
|
-
experiment = subject.find(
|
45
|
+
experiment = subject.find("basket_text")
|
45
46
|
|
46
|
-
expect(experiment.name).to eq(
|
47
|
+
expect(experiment.name).to eq("basket_text")
|
47
48
|
end
|
48
49
|
|
49
50
|
it "should return nil if experiment not exist" do
|
50
|
-
expect(subject.find(
|
51
|
+
expect(subject.find("non_existent_experiment")).to be_nil
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|