split 3.3.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac2527f0dab7b1f6c2de3e21b02fd933eef302046e7cdd4b8f42da20a3cdf1ba
4
- data.tar.gz: 6332eabde240b1c408ff434850b7ac520b3081bfd5fe76f7343259a8eae039b6
3
+ metadata.gz: 1d316599c60ca79cff957c25c44d5901c0c2a86c3631e516b07aeac5afc720d3
4
+ data.tar.gz: 004f09975e36482ab4a56b7bd63fd9d703f067a26d9e9fd99e0a80b6cc2853b5
5
5
  SHA512:
6
- metadata.gz: 331863e4c78e8dabf7eb23551608be301cdd33d4c14186ab47def00485b028c05784f70009fd66d1b3e240963d1cd45b61d2233b651fd0bcbcb79e2871d2a6ad
7
- data.tar.gz: 2c8723105824b9dfc315f88de450be5c18aa32d20e2253a25ca9fcbb6b65b082697c0782719198a2f7b401e66824597a50c3f97dece30a3c9ceccb3fcd62fa95
6
+ metadata.gz: 9001316e86f2e91289523c51097b67dac319ee1cd9a6b27e6f323496258824afe8921fcc306a7ecdc8787406b64f6c8eaa49febf06069afe9532f42218baf8f9
7
+ data.tar.gz: 51b13b3950580e2b446cf688f651632ed2135dec37168e9681e9cf46623ce9707ab8db2b947ca0d1711d0a49d64e1721d4d58ba09b9f5c3fab62ef6f747f5c8f
data/.travis.yml CHANGED
@@ -2,17 +2,19 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0
5
- - 2.1
5
+ - 2.1.10
6
6
  - 2.2.0
7
7
  - 2.2.2
8
- - 2.4.3
9
- - 2.5.1
8
+ - 2.4.5
9
+ - 2.5.3
10
+ - 2.6.0
10
11
 
11
12
  gemfile:
12
13
  - gemfiles/4.2.gemfile
13
14
  - gemfiles/5.0.gemfile
14
15
  - gemfiles/5.1.gemfile
15
16
  - gemfiles/5.2.gemfile
17
+ - gemfiles/6.0.gemfile
16
18
 
17
19
 
18
20
  matrix:
@@ -21,30 +23,41 @@ matrix:
21
23
  gemfile: gemfiles/5.0.gemfile
22
24
  - rvm: 1.9.3
23
25
  gemfile: gemfiles/5.1.gemfile
26
+ - rvm: 1.9.3
27
+ gemfile: gemfiles/5.2.gemfile
28
+ - rvm: 1.9.3
29
+ gemfile: gemfiles/6.0.gemfile
24
30
  - rvm: 2.0
25
31
  gemfile: gemfiles/5.0.gemfile
26
32
  - rvm: 2.0
27
33
  gemfile: gemfiles/5.1.gemfile
28
- - rvm: 2.1
34
+ - rvm: 2.0
35
+ gemfile: gemfiles/5.2.gemfile
36
+ - rvm: 2.0
37
+ gemfile: gemfiles/6.0.gemfile
38
+ - rvm: 2.1.10
29
39
  gemfile: gemfiles/5.0.gemfile
30
- - rvm: 2.1
40
+ - rvm: 2.1.10
31
41
  gemfile: gemfiles/5.1.gemfile
42
+ - rvm: 2.1.10
43
+ gemfile: gemfiles/5.2.gemfile
44
+ - rvm: 2.1.10
45
+ gemfile: gemfiles/6.0.gemfile
32
46
  - rvm: 2.2.0
33
47
  gemfile: gemfiles/5.0.gemfile
34
48
  - rvm: 2.2.0
35
49
  gemfile: gemfiles/5.1.gemfile
36
- - rvm: 1.9.3
37
- gemfile: gemfiles/5.2.gemfile
38
- - rvm: 2.0
39
- gemfile: gemfiles/5.2.gemfile
40
- - rvm: 2.1
41
- gemfile: gemfiles/5.2.gemfile
42
50
  - rvm: 2.2.0
43
51
  gemfile: gemfiles/5.2.gemfile
44
-
52
+ - rvm: 2.2.0
53
+ gemfile: gemfiles/6.0.gemfile
54
+ - rvm: 2.2.2
55
+ gemfile: gemfiles/6.0.gemfile
56
+ - rvm: 2.4.5
57
+ gemfile: gemfiles/6.0.gemfile
45
58
 
46
59
  before_install:
47
- - gem update --system && gem install bundler
60
+ - gem install bundler --version=1.17.3
48
61
 
49
62
  script:
50
63
  - RAILS_ENV=test bundle exec rake spec && bundle exec codeclimate-test-reporter
data/Appraisals CHANGED
@@ -13,3 +13,7 @@ end
13
13
  appraise "5.2" do
14
14
  gem "rails", "~> 5.2"
15
15
  end
16
+
17
+ appraise "6.0" do
18
+ gem 'rails', '~> 6.0.0.beta3'
19
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,56 @@
1
+ ## 3.3.2 (April 12th, 2019)
2
+
3
+ Features:
4
+ - Added uptime robot to configuration.rb (@razel1982, #556)
5
+ - Check to see if being run in Rails application and run in before_initialize (@husteadrobert, #555)
6
+
7
+ Bugfixes:
8
+ - Fix error message interpolation (@hanibash, #553)
9
+ - Fix Bigdecimal warnings (@agraves, #551)
10
+ - Avoid hitting up on redis for robots/excluded users. (@andrehjr, #544)
11
+ - Checks for defined?(request) on Helper#exclude_visitor?. (@andrehjr)
12
+
13
+ Misc:
14
+ - Update travis to add Rails 6 (@edmilton, #559)
15
+ - Fix broken specs in developement environment (@dougpetronilio, #557)
16
+
17
+ ## 3.3.1 (January 11th, 2019)
18
+
19
+ Features:
20
+ - Filter some more bots (@janosch-x, #542)
21
+
22
+ Bugfixes:
23
+ - Fix Dashboard Pagination Helper typo (@cattekin, #541)
24
+ - Do not storage alternative in cookie if experiment has a winner (@sadhu89, #539)
25
+ - fix user participating alternative not found (@NaturalHokke, #536)
26
+
27
+ Misc:
28
+ - Tweak RSpec instructions (@eliotsykes, #540)
29
+ - Improve README regarding rspec usage (@vermaxik, #538)
30
+
31
+ ## 3.3.0 (August 13th, 2018)
32
+
33
+ Features:
34
+
35
+ - Added pagination for dashboard (@GeorgeGorbanev, #518)
36
+ - Add Facebot crawler to list of bots (@pfeiffer, #530)
37
+ - Ignore previewing requests (@pfeiffer, #531)
38
+ - Fix binding of ignore_filter (@pfeiffer, #533)
39
+
40
+ Bugfixes:
41
+
42
+ - Fix cookie header duplication (@andrehjr, #522)
43
+
44
+ Performance:
45
+
46
+ - Improve performance of RedisInterface#make_list_length by using LTRIM command (@mlovic, #509)
47
+
48
+ Misc:
49
+
50
+ - Update development dependencies
51
+ - test rails 5.2 on travis (@lostapathy, #524)
52
+ - update ruby versions for travis (@lostapathy, #525)
53
+
1
54
  ## 3.2.0 (September 21st, 2017)
2
55
 
3
56
  Features:
data/README.md CHANGED
@@ -159,15 +159,15 @@ In the event you want to disable all tests without having to know the individual
159
159
 
160
160
  It is not required to send `SPLIT_DISABLE=false` to activate Split.
161
161
 
162
- To aid testing with RSpec, write `split_helper.rb` and call `use_ab_test(alternatives_by_experiment)` in your specs as instructed below:
162
+
163
+ ### Rspec Helper
164
+ To aid testing with RSpec, write `spec/support/split_helper.rb` and call `use_ab_test(alternatives_by_experiment)` in your specs as instructed below:
163
165
 
164
166
  ```ruby
165
- # Recommended path for this file is 'spec/support/split_helper.rb', and you will need to ensure it
166
- # is `require`-d by rails_helper.rb or spec_helper.rb
167
+ # Create a file with these contents at 'spec/support/split_helper.rb'
168
+ # and ensure it is `require`d in your rails_helper.rb or spec_helper.rb
167
169
  module SplitHelper
168
170
 
169
- # Usage:
170
- #
171
171
  # Force a specific experiment alternative to always be returned:
172
172
  # use_ab_test(signup_form: "single_page")
173
173
  #
@@ -176,18 +176,26 @@ module SplitHelper
176
176
  #
177
177
  def use_ab_test(alternatives_by_experiment)
178
178
  allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment|
179
- alternative =
180
- alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
179
+ alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
181
180
  end
182
181
  end
183
182
  end
184
183
 
184
+ # Make the `use_ab_test` method available to all specs:
185
185
  RSpec.configure do |config|
186
- # Make the `use_ab_test` method available to all specs:
187
186
  config.include SplitHelper
188
187
  end
189
188
  ```
190
189
 
190
+ Now you can call `use_ab_test(alternatives_by_experiment)` in your specs, for example:
191
+ ```ruby
192
+ it "registers using experimental signup" do
193
+ use_ab_test experiment_name: "alternative_name"
194
+ post "/signups"
195
+ ...
196
+ end
197
+ ```
198
+
191
199
 
192
200
  ### Starting experiments manually
193
201
 
@@ -210,6 +218,12 @@ The user will then always see the alternative they started with.
210
218
 
211
219
  Any old unfinished experiment key will be deleted from the user's data storage if the experiment had been removed or is over and a winner had been chosen. This allows a user to enroll into any new experiment in cases when the `allow_multiple_experiments` config option is set to `false`.
212
220
 
221
+ ### Reset experiments manually
222
+
223
+ By default Split automatically resets the experiment whenever it detects the configuration for an experiment has changed (e.g. you call `ab_test` with different alternatives). You can prevent this by setting the option `reset_manually` to `true`.
224
+
225
+ You may want to do this when you want to change something, like the variants' names, the metadata about an experiment, etc. without resetting everything.
226
+
213
227
  ### Multiple experiments at once
214
228
 
215
229
  By default Split will avoid users participating in multiple experiments at once. This means you are less likely to skew results by adding in more variation to your tests.
@@ -450,6 +464,7 @@ Split.configure do |config|
450
464
  config.enabled = true
451
465
  config.persistence = Split::Persistence::SessionAdapter
452
466
  #config.start_manually = false ## new test will have to be started manually from the admin panel. default false
467
+ #config.reset_manually = false ## if true, it never resets the experiment data, even if the configuration changes
453
468
  config.include_rails_helper = true
454
469
  config.redis = "redis://custom.redis.url:6380"
455
470
  end
@@ -935,4 +950,4 @@ Please note that this project is released with a [Contributor Code of Conduct](C
935
950
 
936
951
  ## Copyright
937
952
 
938
- [MIT License](LICENSE) © 2018 [Andrew Nesbitt](https://github.com/andrew).
953
+ [MIT License](LICENSE) © 2019 [Andrew Nesbitt](https://github.com/andrew).
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "codeclimate-test-reporter"
7
+ gem "rails", "~> 6.0.0.beta3"
8
+
9
+ gemspec path: "../"
@@ -3,7 +3,7 @@ module Split
3
3
  module CombinedExperimentsHelper
4
4
  def ab_combined_test(metric_descriptor, control = nil, *alternatives)
5
5
  return nil unless experiment = find_combined_experiment(metric_descriptor)
6
- raise(Split::InvalidExperimentsFormatError, 'Unable to find experiment #{metric_descriptor} in configuration') if experiment[:combined_experiments].nil?
6
+ raise(Split::InvalidExperimentsFormatError, "Unable to find experiment #{metric_descriptor} in configuration") if experiment[:combined_experiments].nil?
7
7
 
8
8
  alternative = nil
9
9
  weighted_alternatives = nil
@@ -61,12 +61,14 @@ module Split
61
61
  'ColdFusion' => 'ColdFusion http library',
62
62
  'EventMachine HttpClient' => 'Ruby http library',
63
63
  'Go http package' => 'Go http library',
64
+ 'Go-http-client' => 'Go http library',
64
65
  'Java' => 'Generic Java http library',
65
66
  'libwww-perl' => 'Perl client-server library loved by script kids',
66
67
  'lwp-trivial' => 'Another Perl library loved by script kids',
67
68
  'Python-urllib' => 'Python http library',
68
69
  'PycURL' => 'Python http library',
69
70
  'Test Certificate Info' => 'C http library?',
71
+ 'Typhoeus' => 'Ruby http library',
70
72
  'Wget' => 'wget unix CLI http client',
71
73
 
72
74
  # URL expanders / previewers
@@ -91,10 +93,12 @@ module Split
91
93
 
92
94
  # Uptime monitoring
93
95
  'check_http' => 'Nagios monitor',
96
+ 'GoogleStackdriverMonitoring' => 'Google Cloud monitor',
94
97
  'NewRelicPinger' => 'NewRelic monitor',
95
98
  'Panopta' => 'Monitoring service',
96
99
  'Pingdom' => 'Pingdom monitoring',
97
100
  'SiteUptime' => 'Site monitoring services',
101
+ 'UptimeRobot' => 'Monitoring service',
98
102
 
99
103
  # ???
100
104
  'DigitalPersona Fingerprint Software' => 'HP Fingerprint scanner',
@@ -19,9 +19,9 @@ module Split
19
19
 
20
20
  def round(number, precision = 2)
21
21
  begin
22
- BigDecimal.new(number.to_s)
22
+ BigDecimal(number.to_s)
23
23
  rescue ArgumentError
24
- BigDecimal.new(0)
24
+ BigDecimal(0)
25
25
  end.round(precision).to_f
26
26
  end
27
27
 
@@ -25,7 +25,7 @@ module Split
25
25
  html << current_page_tag
26
26
  html << next_page_tag if show_next_page_tag?(collection)
27
27
  html << ellipsis_tag if show_last_ellipsis_tag?(collection)
28
- html << last_page_tagcollection if show_last_page_tag?(collection)
28
+ html << last_page_tag(collection) if show_last_page_tag?(collection)
29
29
  html.join
30
30
  end
31
31
 
data/lib/split/helper.rb CHANGED
@@ -8,7 +8,7 @@ module Split
8
8
  def ab_test(metric_descriptor, control = nil, *alternatives)
9
9
  begin
10
10
  experiment = ExperimentCatalog.find_or_initialize(metric_descriptor, control, *alternatives)
11
- alternative = if Split.configuration.enabled
11
+ alternative = if Split.configuration.enabled && !exclude_visitor?
12
12
  experiment.save
13
13
  raise(Split::InvalidExperimentsFormatError) unless (Split.configuration.experiments || {}).fetch(experiment.name.to_sym, {})[:combined_experiments].nil?
14
14
  trial = Trial.new(:user => ab_user, :experiment => experiment,
@@ -122,7 +122,7 @@ module Split
122
122
  end
123
123
 
124
124
  def exclude_visitor?
125
- instance_exec(request, &Split.configuration.ignore_filter) || is_ignored_ip_address? || is_robot? || is_preview?
125
+ defined?(request) && (instance_exec(request, &Split.configuration.ignore_filter) || is_ignored_ip_address? || is_robot? || is_preview?)
126
126
  end
127
127
 
128
128
  def is_robot?
data/lib/split/trial.rb CHANGED
@@ -68,10 +68,8 @@ module Split
68
68
  if exclude_user?
69
69
  self.alternative = @experiment.control
70
70
  else
71
- value = @user[@experiment.key]
72
- if value
73
- self.alternative = value
74
- else
71
+ self.alternative = @user[@experiment.key]
72
+ if alternative.nil?
75
73
  self.alternative = @experiment.next_alternative
76
74
 
77
75
  # Increment the number of participants since we are actually choosing a new alternative
@@ -82,7 +80,7 @@ module Split
82
80
  end
83
81
  end
84
82
 
85
- @user[@experiment.key] = alternative.name if should_store_alternative?
83
+ @user[@experiment.key] = alternative.name if !@experiment.has_winner? && should_store_alternative?
86
84
  @alternative_choosen = true
87
85
  run_callback context, Split.configuration.on_trial unless @options[:disabled] || Split.configuration.disabled?
88
86
  alternative
data/lib/split/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
  module Split
3
3
  MAJOR = 3
4
4
  MINOR = 3
5
- PATCH = 0
5
+ PATCH = 2
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
data/lib/split.rb CHANGED
@@ -66,4 +66,11 @@ module Split
66
66
  end
67
67
  end
68
68
 
69
- Split.configure {}
69
+ # Check to see if being run in a Rails application. If so, wait until before_initialize to run configuration so Gems that create ENV variables have the chance to initialize first.
70
+ if defined?(::Rails)
71
+ class Railtie < Rails::Railtie
72
+ config.before_initialize { Split.configure {} }
73
+ end
74
+ else
75
+ Split.configure {}
76
+ end
data/spec/helper_spec.rb CHANGED
@@ -564,6 +564,11 @@ describe Split::Helper do
564
564
  expect(alternative).to eq experiment.control.name
565
565
  end
566
566
 
567
+ it 'should not create a experiment' do
568
+ ab_test('link_color', 'blue', 'red')
569
+ expect(Split::Experiment.new('link_color')).to be_a_new_record
570
+ end
571
+
567
572
  it "should not increment the participation count" do
568
573
 
569
574
  previous_red_count = Split::Alternative.new('red', 'link_color').participant_count
data/spec/trial_spec.rb CHANGED
@@ -176,6 +176,14 @@ describe Split::Trial do
176
176
 
177
177
  expect_alternative(trial, 'basket')
178
178
  end
179
+
180
+ context "when alternative is not found" do
181
+ it "falls back on next_alternative" do
182
+ user[experiment.key] = 'notfound'
183
+ expect(experiment).to receive(:next_alternative).and_call_original
184
+ expect_alternative(trial, alternatives)
185
+ end
186
+ end
179
187
  end
180
188
 
181
189
  context "when user is a new participant" do
@@ -275,5 +283,17 @@ describe Split::Trial do
275
283
  trial.choose!
276
284
  end
277
285
  end
286
+
287
+ context 'when experiment has winner' do
288
+ let(:trial) do
289
+ experiment.winner = 'cart'
290
+ Split::Trial.new(:user => user, :experiment => experiment)
291
+ end
292
+
293
+ it 'does not store' do
294
+ expect(user).to_not receive("[]=")
295
+ trial.choose!
296
+ end
297
+ end
278
298
  end
279
299
  end
data/split.gemspec CHANGED
@@ -34,11 +34,12 @@ Gem::Specification.new do |s|
34
34
  s.add_dependency 'sinatra', '>= 1.2.6'
35
35
  s.add_dependency 'simple-random', '>= 0.9.3'
36
36
 
37
- s.add_development_dependency 'bundler', '~> 1.14'
37
+ s.add_development_dependency 'bundler', '>= 1.17'
38
38
  s.add_development_dependency 'simplecov', '~> 0.15'
39
39
  s.add_development_dependency 'rack-test', '~> 0.6'
40
40
  s.add_development_dependency 'rake', '~> 12'
41
41
  s.add_development_dependency 'rspec', '~> 3.7'
42
42
  s.add_development_dependency 'pry', '~> 0.10'
43
43
  s.add_development_dependency 'fakeredis', '~> 0.7'
44
+ s.add_development_dependency 'rails', '>= 4.2'
44
45
  end
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.3.0
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-13 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.14'
61
+ version: '1.17'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.14'
68
+ version: '1.17'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.7'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '4.2'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '4.2'
153
167
  description:
154
168
  email:
155
169
  - andrewnez@gmail.com
@@ -176,6 +190,7 @@ files:
176
190
  - gemfiles/5.0.gemfile
177
191
  - gemfiles/5.1.gemfile
178
192
  - gemfiles/5.2.gemfile
193
+ - gemfiles/6.0.gemfile
179
194
  - lib/split.rb
180
195
  - lib/split/algorithms/block_randomization.rb
181
196
  - lib/split/algorithms/weighted_sample.rb
@@ -270,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
285
  version: 2.0.0
271
286
  requirements: []
272
287
  rubyforge_project: split
273
- rubygems_version: 2.7.3
288
+ rubygems_version: 2.7.6
274
289
  signing_key:
275
290
  specification_version: 4
276
291
  summary: Rack based split testing framework