split 4.0.0.pre2 → 4.0.2

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