split 3.0.0 → 3.2.0

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
  SHA1:
3
- metadata.gz: b0a3a695f8950186c2af7c9fd33b4201f785656a
4
- data.tar.gz: f24adb5a893e0cac0cbf29c06ec86d9ae692c1a2
3
+ metadata.gz: 861fb73c59529de9a24f3a78ddd0b5cbe257eb8b
4
+ data.tar.gz: dd67eac616dd9435c3a0ca448de504b3824bccb8
5
5
  SHA512:
6
- metadata.gz: 41138ef7911a9843cbc3fa81f78b28184087dacfff4d291d820ae32faf343fce0a9552f4d0123d647751ceadf8c1f242d44bd7e476e50a69165a49b13e422e27
7
- data.tar.gz: c8cfabeb28e143872e7c81f5d3e4dd28f2cb9c8d274f21a31481eaa52725eed06876ef6959ad44aacb84c47f064c84953d2edffd4767951774011037aff28e96
6
+ metadata.gz: d078b157629b473b654b751c18fe11ddae08486f38bce2fef2bdd71b7a8536ce048204adaf9b1e242e6cf76f1c33650db91994e34a23734ecaf4357663b750cf
7
+ data.tar.gz: aa994978184569f624b9d5bb3503b93b498ef4601bb1989fe2e16eabee07a0450adc9555c02c251d70d9a73dce65e40bac0e05bf071dc8d229e4ab87c0b817ec
data/.rubocop.yml CHANGED
@@ -716,7 +716,7 @@ Style/LineEndConcatenation:
716
716
  line end.
717
717
  Enabled: false
718
718
 
719
- Style/MethodCallParentheses:
719
+ Style/MethodCallWithoutArgsParentheses:
720
720
  Description: 'Do not use parentheses for method calls with no arguments.'
721
721
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
722
722
  Enabled: false
@@ -816,7 +816,7 @@ Style/OneLineConditional:
816
816
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
817
817
  Enabled: false
818
818
 
819
- Style/OpMethod:
819
+ Naming/BinaryOperatorParameter:
820
820
  Description: 'When defining binary operators, name the argument other.'
821
821
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
822
822
  Enabled: false
data/.travis.yml CHANGED
@@ -1,13 +1,38 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.0
3
+ - 1.9.3
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2.0
7
+ - 2.2.2
8
+ - 2.4.2
4
9
 
5
10
  gemfile:
6
11
  - gemfiles/4.2.gemfile
7
12
  - gemfiles/5.0.gemfile
13
+ - gemfiles/5.1.gemfile
14
+
15
+ matrix:
16
+ exclude:
17
+ - rvm: 1.9.3
18
+ gemfile: gemfiles/5.0.gemfile
19
+ - rvm: 1.9.3
20
+ gemfile: gemfiles/5.1.gemfile
21
+ - rvm: 2.0
22
+ gemfile: gemfiles/5.0.gemfile
23
+ - rvm: 2.0
24
+ gemfile: gemfiles/5.1.gemfile
25
+ - rvm: 2.1
26
+ gemfile: gemfiles/5.0.gemfile
27
+ - rvm: 2.1
28
+ gemfile: gemfiles/5.1.gemfile
29
+ - rvm: 2.2.0
30
+ gemfile: gemfiles/5.0.gemfile
31
+ - rvm: 2.2.0
32
+ gemfile: gemfiles/5.1.gemfile
8
33
 
9
34
  before_install:
10
- - gem install bundler
35
+ - gem update --system && gem install bundler
11
36
 
12
37
  script:
13
38
  - RAILS_ENV=test bundle exec rake spec && bundle exec codeclimate-test-reporter
data/Appraisals CHANGED
@@ -6,3 +6,8 @@ appraise "5.0" do
6
6
  gem "rails", "~> 5.0"
7
7
  gem "sinatra", git: "https://github.com/sinatra/sinatra"
8
8
  end
9
+
10
+ appraise "5.1" do
11
+ gem "rails", "~> 5.1"
12
+ gem "sinatra", git: "https://github.com/sinatra/sinatra"
13
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ ## 3.2.0 (September 21st, 2017)
2
+
3
+ Features:
4
+
5
+ - Allow configuration of how often winning alternatives are recalculated (@patbl, #501)
6
+
7
+ Bugfixes:
8
+
9
+ - Avoid z_score numeric exception for conversion rates >1 (@cmantas, #503)
10
+ - Fix combined experiments (@semanticart, #502)
11
+
12
+ ## 3.1.1 (August 30th, 2017)
13
+
14
+ Bugfixes:
15
+
16
+ - Bring back support for ruby 1.9.3 and greater (rubygems 2.0.0 or greater now required) (@patbl, #498)
17
+
18
+ Misc:
19
+
20
+ - Document testing with RSpec (@eliotsykes, #495)
21
+
22
+ ## 3.1.0 (August 14th, 2017)
23
+
24
+ Features:
25
+
26
+ - Support for combined experiments (@daviddening, #493)
27
+ - Rewrite CookieAdapter to work with Rack::Request and Rack::Response directly (@andrehjr, #490)
28
+ - Enumeration of a User's Experiments that Respects the db_failover Option(@MarkRoddy, #487)
29
+
30
+ Bugfixes:
31
+
32
+ - Blocked a few more common bot user agents (@kylerippey, #485)
33
+
34
+ Misc:
35
+
36
+ - Repository Audit by Maintainer.io (@RichardLitt, #484)
37
+ - Update development dependencies
38
+ - Test on ruby 2.4.1
39
+ - Test compatibility with rails 5.1
40
+ - Add uris to metadata section in gemspec
41
+
1
42
  ## 3.0.0 (March 30th, 2017)
2
43
 
3
44
  Features:
data/CONTRIBUTING.md CHANGED
@@ -1,13 +1,62 @@
1
- ## Contributing
1
+ # Contributing to Split
2
2
 
3
- *Note*: Split requires Ruby 1.9.2 or higher.
3
+ Want to contribute to Split? That's great! Here are a couple of guidelines that will help you contribute. Before we get started: Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms.
4
+
5
+ #### Overview
6
+
7
+ * [Contribution workflow](#contribution-workflow)
8
+ * [Setup instructions](#setup-instructions)
9
+ * [Reporting a bug](#reporting-a-bug)
10
+ * [Contributing to an existing issue](#contributing-to-an-existing-issue)
11
+ * [Our labels](#our-labels)
12
+ * [Additional info](#additional-info)
13
+
14
+ ## Contribution workflow
4
15
 
5
16
  * Fork the project.
6
17
  * Make your feature addition or bug fix.
7
18
  * Add tests for it. This is important so I don't break it in a
8
19
  future version unintentionally.
9
20
  * Add documentation if necessary.
10
- * Commit, do not mess with rakefile, version, or history.
11
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
21
+ * Commit. Do not mess with the Rakefile, version, or history.
22
+ (If you want to have your own version, that is fine. But bump version in a commit by itself I can ignore when I pull.)
12
23
  * Send a pull request. Bonus points for topic branches.
13
- * Discussion at the [Google Group](https://groups.google.com/d/forum/split-ruby)
24
+ * Discussion at the [Google Group](https://groups.google.com/d/forum/split-ruby)
25
+
26
+ ## Setup instructions
27
+
28
+ You can find in-depth instructions to install in our [README](https://github.com/splitrb/split/blob/master/README.md).
29
+
30
+ *Note*: Split requires Ruby 1.9.2 or higher.
31
+
32
+ ## Reporting a bug
33
+
34
+ So you've found a bug, and want to help us fix it? Before filing a bug report, please double-check the bug hasn't already been reported. You can do so [on our issue tracker](https://github.com/splitrb/split/issues?q=is%3Aissue+is%3Aopen+label%3Abug). If something hasn't been raised, you can go ahead and create a new issue with the following information:
35
+
36
+ * When did the error happen?
37
+ * How can the error be reproduced?
38
+ * If possible, please also provide an error message or a screenshot to illustrate the problem.
39
+
40
+ If you want to be really thorough, there is a great overview on Stack Overflow of [what you should consider when reporting a bug](http://stackoverflow.com/questions/240323/how-to-report-bugs-the-smart-way).
41
+
42
+ It goes without saying that you're welcome to help investigate further and/or find a fix for the bug. If you want to do so, just mention it in your bug report and offer your help!
43
+
44
+ ## Contributing to an existing issue
45
+
46
+ ### Finding an issue to work on
47
+
48
+ We've got a few open issues and are always glad to get help on that front. You can view the list of issues [here](https://github.com/splitrb/split/issues). Most of the issues are labelled, so you can use the labels to get an idea of which issue could be a good fit for you. (Here's [a good article](https://medium.freecodecamp.com/finding-your-first-open-source-project-or-bug-to-work-on-1712f651e5ba) on how to find your first bug to fix).
49
+
50
+ Before getting to work, take a look at the issue and at the conversation around it. Has someone already offered to work on the issue? Has someone been assigned to the issue? If so, you might want to check with them to see whether they're still actively working on it.
51
+
52
+ If the issue is a few months old, it might be a good idea to write a short comment to double-check that the issue or feature is still a valid one to jump on.
53
+
54
+ Feel free to ask for more detail on what is expected: are there any more details or specifications you need to know?
55
+
56
+ And if at any point you get stuck: don't hesitate to ask for help.
57
+
58
+ ### Making your contribution
59
+
60
+ We've outlined the contribution workflow [here](#contribution-workflow). If you're a first-timer, don't worry! GitHub has a ton of guides to help you through your first pull request: You can find out more about pull requests [here](https://help.github.com/articles/about-pull-requests/) and about creating a pull request [here](https://help.github.com/articles/creating-a-pull-request/).
61
+
62
+ Especially if you're a newcomer to Open Source and you've found some little bumps along the way while contributing, we recommend you write about them. [Here](https://medium.freecodecamp.com/new-contributors-to-open-source-please-blog-more-920af14cffd)'s a great article about why writing about your experience is important; this will encourage other beginners to try their luck at Open Source, too!
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Andrew Nesbitt
3
+ Copyright (c) 2017 Andrew Nesbitt
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,97 +1,28 @@
1
1
  # [Split](http://libraries.io/rubygems/split)
2
2
 
3
- Split is a rack based ab testing framework designed to work with Rails, Sinatra or any other rack based app.
4
-
5
- Split is heavily inspired by the Abingo and Vanity rails ab testing plugins and Resque in its use of Redis.
6
-
7
- Split is designed to be hacker friendly, allowing for maximum customisation and extensibility.
8
-
9
3
  [![Gem Version](https://badge.fury.io/rb/split.svg)](http://badge.fury.io/rb/split)
10
4
  [![Build Status](https://secure.travis-ci.org/splitrb/split.svg?branch=master)](http://travis-ci.org/splitrb/split)
11
5
  [![Code Climate](https://codeclimate.com/github/splitrb/split/badges/gpa.svg)](https://codeclimate.com/github/splitrb/split)
12
6
  [![Test Coverage](https://codeclimate.com/github/splitrb/split/badges/coverage.svg)](https://codeclimate.com/github/splitrb/split/coverage)
7
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
13
8
 
9
+ > 📈 The Rack Based A/B testing framework http://libraries.io/rubygems/split
14
10
 
15
- # Backers
16
-
17
- Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/split#backer)]
18
-
19
- <a href="https://opencollective.com/split/backer/0/website" target="_blank"><img src="https://opencollective.com/split/backer/0/avatar.svg"></a>
20
- <a href="https://opencollective.com/split/backer/1/website" target="_blank"><img src="https://opencollective.com/split/backer/1/avatar.svg"></a>
21
- <a href="https://opencollective.com/split/backer/2/website" target="_blank"><img src="https://opencollective.com/split/backer/2/avatar.svg"></a>
22
- <a href="https://opencollective.com/split/backer/3/website" target="_blank"><img src="https://opencollective.com/split/backer/3/avatar.svg"></a>
23
- <a href="https://opencollective.com/split/backer/4/website" target="_blank"><img src="https://opencollective.com/split/backer/4/avatar.svg"></a>
24
- <a href="https://opencollective.com/split/backer/5/website" target="_blank"><img src="https://opencollective.com/split/backer/5/avatar.svg"></a>
25
- <a href="https://opencollective.com/split/backer/6/website" target="_blank"><img src="https://opencollective.com/split/backer/6/avatar.svg"></a>
26
- <a href="https://opencollective.com/split/backer/7/website" target="_blank"><img src="https://opencollective.com/split/backer/7/avatar.svg"></a>
27
- <a href="https://opencollective.com/split/backer/8/website" target="_blank"><img src="https://opencollective.com/split/backer/8/avatar.svg"></a>
28
- <a href="https://opencollective.com/split/backer/9/website" target="_blank"><img src="https://opencollective.com/split/backer/9/avatar.svg"></a>
29
- <a href="https://opencollective.com/split/backer/10/website" target="_blank"><img src="https://opencollective.com/split/backer/10/avatar.svg"></a>
30
- <a href="https://opencollective.com/split/backer/11/website" target="_blank"><img src="https://opencollective.com/split/backer/11/avatar.svg"></a>
31
- <a href="https://opencollective.com/split/backer/12/website" target="_blank"><img src="https://opencollective.com/split/backer/12/avatar.svg"></a>
32
- <a href="https://opencollective.com/split/backer/13/website" target="_blank"><img src="https://opencollective.com/split/backer/13/avatar.svg"></a>
33
- <a href="https://opencollective.com/split/backer/14/website" target="_blank"><img src="https://opencollective.com/split/backer/14/avatar.svg"></a>
34
- <a href="https://opencollective.com/split/backer/15/website" target="_blank"><img src="https://opencollective.com/split/backer/15/avatar.svg"></a>
35
- <a href="https://opencollective.com/split/backer/16/website" target="_blank"><img src="https://opencollective.com/split/backer/16/avatar.svg"></a>
36
- <a href="https://opencollective.com/split/backer/17/website" target="_blank"><img src="https://opencollective.com/split/backer/17/avatar.svg"></a>
37
- <a href="https://opencollective.com/split/backer/18/website" target="_blank"><img src="https://opencollective.com/split/backer/18/avatar.svg"></a>
38
- <a href="https://opencollective.com/split/backer/19/website" target="_blank"><img src="https://opencollective.com/split/backer/19/avatar.svg"></a>
39
- <a href="https://opencollective.com/split/backer/20/website" target="_blank"><img src="https://opencollective.com/split/backer/20/avatar.svg"></a>
40
- <a href="https://opencollective.com/split/backer/21/website" target="_blank"><img src="https://opencollective.com/split/backer/21/avatar.svg"></a>
41
- <a href="https://opencollective.com/split/backer/22/website" target="_blank"><img src="https://opencollective.com/split/backer/22/avatar.svg"></a>
42
- <a href="https://opencollective.com/split/backer/23/website" target="_blank"><img src="https://opencollective.com/split/backer/23/avatar.svg"></a>
43
- <a href="https://opencollective.com/split/backer/24/website" target="_blank"><img src="https://opencollective.com/split/backer/24/avatar.svg"></a>
44
- <a href="https://opencollective.com/split/backer/25/website" target="_blank"><img src="https://opencollective.com/split/backer/25/avatar.svg"></a>
45
- <a href="https://opencollective.com/split/backer/26/website" target="_blank"><img src="https://opencollective.com/split/backer/26/avatar.svg"></a>
46
- <a href="https://opencollective.com/split/backer/27/website" target="_blank"><img src="https://opencollective.com/split/backer/27/avatar.svg"></a>
47
- <a href="https://opencollective.com/split/backer/28/website" target="_blank"><img src="https://opencollective.com/split/backer/28/avatar.svg"></a>
48
- <a href="https://opencollective.com/split/backer/29/website" target="_blank"><img src="https://opencollective.com/split/backer/29/avatar.svg"></a>
49
-
50
-
51
- # Sponsors
11
+ Split is a rack based A/B testing framework designed to work with Rails, Sinatra or any other rack based app.
52
12
 
53
- Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/split#sponsor)]
54
-
55
- <a href="https://opencollective.com/split/sponsor/0/website" target="_blank"><img src="https://opencollective.com/split/sponsor/0/avatar.svg"></a>
56
- <a href="https://opencollective.com/split/sponsor/1/website" target="_blank"><img src="https://opencollective.com/split/sponsor/1/avatar.svg"></a>
57
- <a href="https://opencollective.com/split/sponsor/2/website" target="_blank"><img src="https://opencollective.com/split/sponsor/2/avatar.svg"></a>
58
- <a href="https://opencollective.com/split/sponsor/3/website" target="_blank"><img src="https://opencollective.com/split/sponsor/3/avatar.svg"></a>
59
- <a href="https://opencollective.com/split/sponsor/4/website" target="_blank"><img src="https://opencollective.com/split/sponsor/4/avatar.svg"></a>
60
- <a href="https://opencollective.com/split/sponsor/5/website" target="_blank"><img src="https://opencollective.com/split/sponsor/5/avatar.svg"></a>
61
- <a href="https://opencollective.com/split/sponsor/6/website" target="_blank"><img src="https://opencollective.com/split/sponsor/6/avatar.svg"></a>
62
- <a href="https://opencollective.com/split/sponsor/7/website" target="_blank"><img src="https://opencollective.com/split/sponsor/7/avatar.svg"></a>
63
- <a href="https://opencollective.com/split/sponsor/8/website" target="_blank"><img src="https://opencollective.com/split/sponsor/8/avatar.svg"></a>
64
- <a href="https://opencollective.com/split/sponsor/9/website" target="_blank"><img src="https://opencollective.com/split/sponsor/9/avatar.svg"></a>
65
- <a href="https://opencollective.com/split/sponsor/10/website" target="_blank"><img src="https://opencollective.com/split/sponsor/10/avatar.svg"></a>
66
- <a href="https://opencollective.com/split/sponsor/11/website" target="_blank"><img src="https://opencollective.com/split/sponsor/11/avatar.svg"></a>
67
- <a href="https://opencollective.com/split/sponsor/12/website" target="_blank"><img src="https://opencollective.com/split/sponsor/12/avatar.svg"></a>
68
- <a href="https://opencollective.com/split/sponsor/13/website" target="_blank"><img src="https://opencollective.com/split/sponsor/13/avatar.svg"></a>
69
- <a href="https://opencollective.com/split/sponsor/14/website" target="_blank"><img src="https://opencollective.com/split/sponsor/14/avatar.svg"></a>
70
- <a href="https://opencollective.com/split/sponsor/15/website" target="_blank"><img src="https://opencollective.com/split/sponsor/15/avatar.svg"></a>
71
- <a href="https://opencollective.com/split/sponsor/16/website" target="_blank"><img src="https://opencollective.com/split/sponsor/16/avatar.svg"></a>
72
- <a href="https://opencollective.com/split/sponsor/17/website" target="_blank"><img src="https://opencollective.com/split/sponsor/17/avatar.svg"></a>
73
- <a href="https://opencollective.com/split/sponsor/18/website" target="_blank"><img src="https://opencollective.com/split/sponsor/18/avatar.svg"></a>
74
- <a href="https://opencollective.com/split/sponsor/19/website" target="_blank"><img src="https://opencollective.com/split/sponsor/19/avatar.svg"></a>
75
- <a href="https://opencollective.com/split/sponsor/20/website" target="_blank"><img src="https://opencollective.com/split/sponsor/20/avatar.svg"></a>
76
- <a href="https://opencollective.com/split/sponsor/21/website" target="_blank"><img src="https://opencollective.com/split/sponsor/21/avatar.svg"></a>
77
- <a href="https://opencollective.com/split/sponsor/22/website" target="_blank"><img src="https://opencollective.com/split/sponsor/22/avatar.svg"></a>
78
- <a href="https://opencollective.com/split/sponsor/23/website" target="_blank"><img src="https://opencollective.com/split/sponsor/23/avatar.svg"></a>
79
- <a href="https://opencollective.com/split/sponsor/24/website" target="_blank"><img src="https://opencollective.com/split/sponsor/24/avatar.svg"></a>
80
- <a href="https://opencollective.com/split/sponsor/25/website" target="_blank"><img src="https://opencollective.com/split/sponsor/25/avatar.svg"></a>
81
- <a href="https://opencollective.com/split/sponsor/26/website" target="_blank"><img src="https://opencollective.com/split/sponsor/26/avatar.svg"></a>
82
- <a href="https://opencollective.com/split/sponsor/27/website" target="_blank"><img src="https://opencollective.com/split/sponsor/27/avatar.svg"></a>
83
- <a href="https://opencollective.com/split/sponsor/28/website" target="_blank"><img src="https://opencollective.com/split/sponsor/28/avatar.svg"></a>
84
- <a href="https://opencollective.com/split/sponsor/29/website" target="_blank"><img src="https://opencollective.com/split/sponsor/29/avatar.svg"></a>
13
+ Split is heavily inspired by the [Abingo](https://github.com/ryanb/abingo) and [Vanity](https://github.com/assaf/vanity) Rails A/B testing plugins and [Resque](https://github.com/resque/resque) in its use of Redis.
85
14
 
15
+ Split is designed to be hacker friendly, allowing for maximum customisation and extensibility.
86
16
 
17
+ ## Install
87
18
 
88
- ## Requirements
19
+ ### Requirements
89
20
 
90
- Split currently requires Ruby 1.9.2 or higher. If your project requires compatibility with Ruby 1.8.x and Rails 2.3, please use v0.8.0.
21
+ Split currently requires Ruby 1.9.3 or higher. If your project requires compatibility with Ruby 1.8.x and Rails 2.3, please use v0.8.0.
91
22
 
92
- Split uses redis as a datastore.
23
+ Split uses Redis as a datastore.
93
24
 
94
- Split only supports redis 2.0 or greater.
25
+ Split only supports Redis 2.0 or greater.
95
26
 
96
27
  If you're on OS X, Homebrew is the simplest way to install Redis:
97
28
 
@@ -100,21 +31,21 @@ brew install redis
100
31
  redis-server /usr/local/etc/redis.conf
101
32
  ```
102
33
 
103
- You now have a Redis daemon running on 6379.
34
+ You now have a Redis daemon running on port `6379`.
104
35
 
105
- ## Setup
36
+ ### Setup
106
37
 
107
38
  ```bash
108
39
  gem install split
109
40
  ```
110
41
 
111
- ### Rails
42
+ #### Rails
112
43
 
113
- Adding `gem 'split'` to your Gemfile will autoload it when rails starts up, as long as you've configured redis it will 'just work'.
44
+ Adding `gem 'split'` to your Gemfile will autoload it when rails starts up, as long as you've configured Redis it will 'just work'.
114
45
 
115
- ### Sinatra
46
+ #### Sinatra
116
47
 
117
- To configure sinatra with Split you need to enable sessions and mix in the helper methods. Add the following lines at the top of your sinatra app:
48
+ To configure Sinatra with Split you need to enable sessions and mix in the helper methods. Add the following lines at the top of your Sinatra app:
118
49
 
119
50
  ```ruby
120
51
  require 'split'
@@ -130,7 +61,7 @@ end
130
61
 
131
62
  ## Usage
132
63
 
133
- To begin your ab test use the `ab_test` method, naming your experiment with the first argument and then the different alternatives which you wish to test on as the other arguments.
64
+ To begin your A/B test use the `ab_test` method, naming your experiment with the first argument and then the different alternatives which you wish to test on as the other arguments.
134
65
 
135
66
  `ab_test` returns one of the alternatives, if a user has already seen that test they will get the same alternative as before, which you can use to split your code on.
136
67
 
@@ -184,6 +115,13 @@ As per this [blog post](http://www.evanmiller.org/how-not-to-run-an-ab-test.html
184
115
 
185
116
  The second option uses simulations from a beta distribution to determine the probability that the given alternative is the winner compared to all other alternatives. You can view these probabilities by clicking on the drop-down menu labeled "Confidence." This option should be used when the experiment has more than just 1 control and 1 alternative. It can also be used for a simple, 2-alternative A/B test.
186
117
 
118
+ Calculating the beta-distribution simulations for a large number of experiments can be slow, so the results are cached. You can specify how often they should be recalculated (the default is once per day).
119
+
120
+ ```ruby
121
+ Split.configure do |config|
122
+ config.winning_alternative_recalculation_interval = 3600 # 1 hour
123
+ end
124
+ ```
187
125
 
188
126
  ## Extras
189
127
 
@@ -220,9 +158,39 @@ In the event you want to disable all tests without having to know the individual
220
158
 
221
159
  It is not required to send `SPLIT_DISABLE=false` to activate Split.
222
160
 
161
+ 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
+ ```ruby
164
+ # Recommended path for this file is 'spec/support/split_helper.rb', and you will need to ensure it
165
+ # is `require`-d by rails_helper.rb or spec_helper.rb
166
+ module SplitHelper
167
+
168
+ # Usage:
169
+ #
170
+ # Force a specific experiment alternative to always be returned:
171
+ # use_ab_test(signup_form: "single_page")
172
+ #
173
+ # Force alternatives for multiple experiments:
174
+ # use_ab_test(signup_form: "single_page", pricing: "show_enterprise_prices")
175
+ #
176
+ def use_ab_test(alternatives_by_experiment)
177
+ allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment|
178
+ alternative =
179
+ alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
180
+ end
181
+ end
182
+ end
183
+
184
+ RSpec.configure do |config|
185
+ # Make the `use_ab_test` method available to all specs:
186
+ config.include SplitHelper
187
+ end
188
+ ```
189
+
190
+
223
191
  ### Starting experiments manually
224
192
 
225
- By default new AB tests will be active right after deployment. In case you would like to start new test a while after
193
+ By default new A/B tests will be active right after deployment. In case you would like to start new test a while after
226
194
  the deploy, you can do it by setting the `start_manually` configuration option to `true`.
227
195
 
228
196
  After choosing this option tests won't be started right after deploy, but after pressing the `Start` button in Split admin dashboard. If a test is deleted from the Split dashboard, then it can only be started after pressing the `Start` button whenever being re-initialized.
@@ -475,7 +443,7 @@ You can override the default configuration options of Split like so:
475
443
 
476
444
  ```ruby
477
445
  Split.configure do |config|
478
- config.db_failover = true # handle redis errors gracefully
446
+ config.db_failover = true # handle Redis errors gracefully
479
447
  config.db_failover_on_db_error = -> (error) { Rails.logger.error(error.message) }
480
448
  config.allow_multiple_experiments = true
481
449
  config.enabled = true
@@ -693,6 +661,35 @@ Once you finish one of the goals, the test is considered to be completed, and fi
693
661
 
694
662
  **Bad Example**: Test both how button color affects signup *and* how it affects login, at the same time. THIS WILL NOT WORK.
695
663
 
664
+ #### Combined Experiments
665
+ If you want to test how how button color affects signup *and* how it affects login, at the same time. Use combined tests
666
+ Configure like so
667
+ ```ruby
668
+ Split.configuration.experiments = {
669
+ :button_color_experiment => {
670
+ :alternatives => ["blue", "green"],
671
+ :combined_experiments => ["button_color_on_signup", "button_color_on_login"]
672
+ }
673
+ }
674
+ ```
675
+
676
+ Starting the combined test starts all combined experiments
677
+ ```ruby
678
+ ab_combined_test(:button_color_experiment)
679
+ ```
680
+ Finish each combined test as normal
681
+
682
+ ```ruby
683
+ ab_finished(:button_color_on_login)
684
+ ab_finished(:button_color_on_signup)
685
+ ```
686
+
687
+ **Additional Configuration**:
688
+ * Be sure to enable `allow_multiple_experiments`
689
+ * In Sinatra include the CombinedExperimentsHelper
690
+ ```
691
+ helpers Split::CombinedExperimentsHelper
692
+ ```
696
693
  ### DB failover solution
697
694
 
698
695
  Due to the fact that Redis has no automatic failover mechanism, it's
@@ -811,12 +808,12 @@ end
811
808
 
812
809
  ## Extensions
813
810
 
814
- - [Split::Export](http://github.com/splitrb/split-export) - easily export ab test data out of Split
815
- - [Split::Analytics](http://github.com/splitrb/split-analytics) - push test data to google analytics
816
- - [Split::Mongoid](https://github.com/MongoHQ/split-mongoid) - store experiment data in mongoid (still uses redis)
817
- - [Split::Cacheable](https://github.com/harrystech/split_cacheable) - automatically create cache buckets per test
818
- - [Split::Counters](https://github.com/bernardkroes/split-counters) - add counters per experiment and alternative
819
- - [Split::Cli](https://github.com/craigmcnamara/split-cli) - a CLI to trigger Split A/B tests
811
+ - [Split::Export](http://github.com/splitrb/split-export) - Easily export A/B test data out of Split.
812
+ - [Split::Analytics](http://github.com/splitrb/split-analytics) - Push test data to Google Analytics.
813
+ - [Split::Mongoid](https://github.com/MongoHQ/split-mongoid) - Store experiment data in mongoid (still uses redis).
814
+ - [Split::Cacheable](https://github.com/harrystech/split_cacheable) - Automatically create cache buckets per test.
815
+ - [Split::Counters](https://github.com/bernardkroes/split-counters) - Add counters per experiment and alternative.
816
+ - [Split::Cli](https://github.com/craigmcnamara/split-cli) - A CLI to trigger Split A/B tests.
820
817
 
821
818
  ## Screencast
822
819
 
@@ -824,15 +821,93 @@ Ryan bates has produced an excellent 10 minute screencast about split on the Rai
824
821
 
825
822
  ## Blogposts
826
823
 
827
- * [A/B Testing with Split in Ruby on Rails](http://grinnick.com/posts/a-b-testing-with-split-in-ruby-on-rails)
828
824
  * [Recipe: A/B testing with KISSMetrics and the split gem](http://robots.thoughtbot.com/post/9595887299/recipe-a-b-testing-with-kissmetrics-and-the-split-gem)
829
825
  * [Rails A/B testing with Split on Heroku](http://blog.nathanhumbert.com/2012/02/rails-ab-testing-with-split-on-heroku.html)
830
826
 
831
- ## Contributors
827
+ ## Backers
828
+
829
+ Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/split#backer)]
830
+
831
+ <a href="https://opencollective.com/split/backer/0/website" target="_blank"><img src="https://opencollective.com/split/backer/0/avatar.svg"></a>
832
+ <a href="https://opencollective.com/split/backer/1/website" target="_blank"><img src="https://opencollective.com/split/backer/1/avatar.svg"></a>
833
+ <a href="https://opencollective.com/split/backer/2/website" target="_blank"><img src="https://opencollective.com/split/backer/2/avatar.svg"></a>
834
+ <a href="https://opencollective.com/split/backer/3/website" target="_blank"><img src="https://opencollective.com/split/backer/3/avatar.svg"></a>
835
+ <a href="https://opencollective.com/split/backer/4/website" target="_blank"><img src="https://opencollective.com/split/backer/4/avatar.svg"></a>
836
+ <a href="https://opencollective.com/split/backer/5/website" target="_blank"><img src="https://opencollective.com/split/backer/5/avatar.svg"></a>
837
+ <a href="https://opencollective.com/split/backer/6/website" target="_blank"><img src="https://opencollective.com/split/backer/6/avatar.svg"></a>
838
+ <a href="https://opencollective.com/split/backer/7/website" target="_blank"><img src="https://opencollective.com/split/backer/7/avatar.svg"></a>
839
+ <a href="https://opencollective.com/split/backer/8/website" target="_blank"><img src="https://opencollective.com/split/backer/8/avatar.svg"></a>
840
+ <a href="https://opencollective.com/split/backer/9/website" target="_blank"><img src="https://opencollective.com/split/backer/9/avatar.svg"></a>
841
+ <a href="https://opencollective.com/split/backer/10/website" target="_blank"><img src="https://opencollective.com/split/backer/10/avatar.svg"></a>
842
+ <a href="https://opencollective.com/split/backer/11/website" target="_blank"><img src="https://opencollective.com/split/backer/11/avatar.svg"></a>
843
+ <a href="https://opencollective.com/split/backer/12/website" target="_blank"><img src="https://opencollective.com/split/backer/12/avatar.svg"></a>
844
+ <a href="https://opencollective.com/split/backer/13/website" target="_blank"><img src="https://opencollective.com/split/backer/13/avatar.svg"></a>
845
+ <a href="https://opencollective.com/split/backer/14/website" target="_blank"><img src="https://opencollective.com/split/backer/14/avatar.svg"></a>
846
+ <a href="https://opencollective.com/split/backer/15/website" target="_blank"><img src="https://opencollective.com/split/backer/15/avatar.svg"></a>
847
+ <a href="https://opencollective.com/split/backer/16/website" target="_blank"><img src="https://opencollective.com/split/backer/16/avatar.svg"></a>
848
+ <a href="https://opencollective.com/split/backer/17/website" target="_blank"><img src="https://opencollective.com/split/backer/17/avatar.svg"></a>
849
+ <a href="https://opencollective.com/split/backer/18/website" target="_blank"><img src="https://opencollective.com/split/backer/18/avatar.svg"></a>
850
+ <a href="https://opencollective.com/split/backer/19/website" target="_blank"><img src="https://opencollective.com/split/backer/19/avatar.svg"></a>
851
+ <a href="https://opencollective.com/split/backer/20/website" target="_blank"><img src="https://opencollective.com/split/backer/20/avatar.svg"></a>
852
+ <a href="https://opencollective.com/split/backer/21/website" target="_blank"><img src="https://opencollective.com/split/backer/21/avatar.svg"></a>
853
+ <a href="https://opencollective.com/split/backer/22/website" target="_blank"><img src="https://opencollective.com/split/backer/22/avatar.svg"></a>
854
+ <a href="https://opencollective.com/split/backer/23/website" target="_blank"><img src="https://opencollective.com/split/backer/23/avatar.svg"></a>
855
+ <a href="https://opencollective.com/split/backer/24/website" target="_blank"><img src="https://opencollective.com/split/backer/24/avatar.svg"></a>
856
+ <a href="https://opencollective.com/split/backer/25/website" target="_blank"><img src="https://opencollective.com/split/backer/25/avatar.svg"></a>
857
+ <a href="https://opencollective.com/split/backer/26/website" target="_blank"><img src="https://opencollective.com/split/backer/26/avatar.svg"></a>
858
+ <a href="https://opencollective.com/split/backer/27/website" target="_blank"><img src="https://opencollective.com/split/backer/27/avatar.svg"></a>
859
+ <a href="https://opencollective.com/split/backer/28/website" target="_blank"><img src="https://opencollective.com/split/backer/28/avatar.svg"></a>
860
+ <a href="https://opencollective.com/split/backer/29/website" target="_blank"><img src="https://opencollective.com/split/backer/29/avatar.svg"></a>
861
+
862
+
863
+ ## Sponsors
832
864
 
833
- Over 70 different people have contributed to the project, you can see them all here: https://github.com/splitrb/split/graphs/contributors
865
+ Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/split#sponsor)]
834
866
 
835
- ## Development
867
+ <a href="https://opencollective.com/split/sponsor/0/website" target="_blank"><img src="https://opencollective.com/split/sponsor/0/avatar.svg"></a>
868
+ <a href="https://opencollective.com/split/sponsor/1/website" target="_blank"><img src="https://opencollective.com/split/sponsor/1/avatar.svg"></a>
869
+ <a href="https://opencollective.com/split/sponsor/2/website" target="_blank"><img src="https://opencollective.com/split/sponsor/2/avatar.svg"></a>
870
+ <a href="https://opencollective.com/split/sponsor/3/website" target="_blank"><img src="https://opencollective.com/split/sponsor/3/avatar.svg"></a>
871
+ <a href="https://opencollective.com/split/sponsor/4/website" target="_blank"><img src="https://opencollective.com/split/sponsor/4/avatar.svg"></a>
872
+ <a href="https://opencollective.com/split/sponsor/5/website" target="_blank"><img src="https://opencollective.com/split/sponsor/5/avatar.svg"></a>
873
+ <a href="https://opencollective.com/split/sponsor/6/website" target="_blank"><img src="https://opencollective.com/split/sponsor/6/avatar.svg"></a>
874
+ <a href="https://opencollective.com/split/sponsor/7/website" target="_blank"><img src="https://opencollective.com/split/sponsor/7/avatar.svg"></a>
875
+ <a href="https://opencollective.com/split/sponsor/8/website" target="_blank"><img src="https://opencollective.com/split/sponsor/8/avatar.svg"></a>
876
+ <a href="https://opencollective.com/split/sponsor/9/website" target="_blank"><img src="https://opencollective.com/split/sponsor/9/avatar.svg"></a>
877
+ <a href="https://opencollective.com/split/sponsor/10/website" target="_blank"><img src="https://opencollective.com/split/sponsor/10/avatar.svg"></a>
878
+ <a href="https://opencollective.com/split/sponsor/11/website" target="_blank"><img src="https://opencollective.com/split/sponsor/11/avatar.svg"></a>
879
+ <a href="https://opencollective.com/split/sponsor/12/website" target="_blank"><img src="https://opencollective.com/split/sponsor/12/avatar.svg"></a>
880
+ <a href="https://opencollective.com/split/sponsor/13/website" target="_blank"><img src="https://opencollective.com/split/sponsor/13/avatar.svg"></a>
881
+ <a href="https://opencollective.com/split/sponsor/14/website" target="_blank"><img src="https://opencollective.com/split/sponsor/14/avatar.svg"></a>
882
+ <a href="https://opencollective.com/split/sponsor/15/website" target="_blank"><img src="https://opencollective.com/split/sponsor/15/avatar.svg"></a>
883
+ <a href="https://opencollective.com/split/sponsor/16/website" target="_blank"><img src="https://opencollective.com/split/sponsor/16/avatar.svg"></a>
884
+ <a href="https://opencollective.com/split/sponsor/17/website" target="_blank"><img src="https://opencollective.com/split/sponsor/17/avatar.svg"></a>
885
+ <a href="https://opencollective.com/split/sponsor/18/website" target="_blank"><img src="https://opencollective.com/split/sponsor/18/avatar.svg"></a>
886
+ <a href="https://opencollective.com/split/sponsor/19/website" target="_blank"><img src="https://opencollective.com/split/sponsor/19/avatar.svg"></a>
887
+ <a href="https://opencollective.com/split/sponsor/20/website" target="_blank"><img src="https://opencollective.com/split/sponsor/20/avatar.svg"></a>
888
+ <a href="https://opencollective.com/split/sponsor/21/website" target="_blank"><img src="https://opencollective.com/split/sponsor/21/avatar.svg"></a>
889
+ <a href="https://opencollective.com/split/sponsor/22/website" target="_blank"><img src="https://opencollective.com/split/sponsor/22/avatar.svg"></a>
890
+ <a href="https://opencollective.com/split/sponsor/23/website" target="_blank"><img src="https://opencollective.com/split/sponsor/23/avatar.svg"></a>
891
+ <a href="https://opencollective.com/split/sponsor/24/website" target="_blank"><img src="https://opencollective.com/split/sponsor/24/avatar.svg"></a>
892
+ <a href="https://opencollective.com/split/sponsor/25/website" target="_blank"><img src="https://opencollective.com/split/sponsor/25/avatar.svg"></a>
893
+ <a href="https://opencollective.com/split/sponsor/26/website" target="_blank"><img src="https://opencollective.com/split/sponsor/26/avatar.svg"></a>
894
+ <a href="https://opencollective.com/split/sponsor/27/website" target="_blank"><img src="https://opencollective.com/split/sponsor/27/avatar.svg"></a>
895
+ <a href="https://opencollective.com/split/sponsor/28/website" target="_blank"><img src="https://opencollective.com/split/sponsor/28/avatar.svg"></a>
896
+ <a href="https://opencollective.com/split/sponsor/29/website" target="_blank"><img src="https://opencollective.com/split/sponsor/29/avatar.svg"></a>
897
+
898
+ ## Contribute
899
+
900
+ Please do! Over 70 different people have contributed to the project, you can see them all here: https://github.com/splitrb/split/graphs/contributors.
901
+
902
+ ### Development
903
+
904
+ The source code is hosted at [GitHub](http://github.com/splitrb/split).
905
+
906
+ Report issues and feature requests on [GitHub Issues](http://github.com/splitrb/split/issues).
907
+
908
+ You can find a discussion form on [Google Groups](https://groups.google.com/d/forum/split-ruby).
909
+
910
+ ### Tests
836
911
 
837
912
  Run the tests like this:
838
913
 
@@ -842,23 +917,21 @@ Run the tests like this:
842
917
  bundle
843
918
  rake spec
844
919
 
845
- Source hosted at [GitHub](http://github.com/splitrb/split).
846
-
847
- Report Issues/Feature requests on [GitHub Issues](http://github.com/splitrb/split/issues).
848
-
849
- Discussion at [Google Groups](https://groups.google.com/d/forum/split-ruby).
850
-
851
- ### Note on Patches/Pull Requests
920
+ ### A Note on Patches and Pull Requests
852
921
 
853
922
  * Fork the project.
854
923
  * Make your feature addition or bug fix.
855
924
  * Add tests for it. This is important so I don't break it in a
856
925
  future version unintentionally.
857
926
  * Add documentation if necessary.
858
- * Commit, do not mess with rakefile, version, or history.
859
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
927
+ * Commit. Do not mess with the rakefile, version, or history.
928
+ (If you want to have your own version, that is fine. But bump the version in a commit by itself, which I can ignore when I pull.)
860
929
  * Send a pull request. Bonus points for topic branches.
861
930
 
931
+ ### Code of Conduct
932
+
933
+ Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
934
+
862
935
  ## Copyright
863
936
 
864
- Copyright (c) 2016 Andrew Nesbitt. See [LICENSE](https://github.com/splitrb/split/blob/master/LICENSE) for details.
937
+ [MIT License](LICENSE) © 2017 [Andrew Nesbitt](https://github.com/andrew).
data/gemfiles/4.2.gemfile CHANGED
@@ -6,4 +6,4 @@ gem "appraisal"
6
6
  gem "codeclimate-test-reporter"
7
7
  gem "rails", "~> 4.2"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
data/gemfiles/5.0.gemfile CHANGED
@@ -5,6 +5,6 @@ source "https://rubygems.org"
5
5
  gem "appraisal"
6
6
  gem "codeclimate-test-reporter"
7
7
  gem "rails", "~> 5.0"
8
- gem "sinatra", :git => "https://github.com/sinatra/sinatra"
8
+ gem "sinatra", git: "https://github.com/sinatra/sinatra"
9
9
 
10
- gemspec :path => "../"
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
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", "~> 5.1"
8
+ gem "sinatra", git: "https://github.com/sinatra/sinatra"
9
+
10
+ gemspec path: "../"
@@ -119,6 +119,9 @@ module Split
119
119
  n_a = alternative.participant_count
120
120
  n_c = control.participant_count
121
121
 
122
+ # can't calculate zscore for P(x) > 1
123
+ return 'N/A' if p_a > 1 || p_c > 1
124
+
122
125
  z_score = Split::Zscore.calculate(p_a, n_a, p_c, n_c)
123
126
  end
124
127
 
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ module Split
3
+ module CombinedExperimentsHelper
4
+ def ab_combined_test(metric_descriptor, control = nil, *alternatives)
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?
7
+
8
+ alternative = nil
9
+ weighted_alternatives = nil
10
+ experiment[:combined_experiments].each do |combined_experiment|
11
+ if alternative.nil?
12
+ if control
13
+ alternative = ab_test(combined_experiment, control, alternatives)
14
+ else
15
+ normalized_alternatives = Split::Configuration.new.normalize_alternatives(experiment[:alternatives])
16
+ alternative = ab_test(combined_experiment, normalized_alternatives[0], *normalized_alternatives[1])
17
+ end
18
+ else
19
+ weighted_alternatives ||= experiment[:alternatives].each_with_object({}) do |alt, memo|
20
+ alt = Alternative.new(alt, experiment[:name]).name
21
+ memo[alt] = (alt == alternative ? 1 : 0)
22
+ end
23
+
24
+ ab_test(combined_experiment, [weighted_alternatives])
25
+ end
26
+ end
27
+ alternative
28
+ end
29
+
30
+ def find_combined_experiment(metric_descriptor)
31
+ raise(Split::InvalidExperimentsFormatError, 'Invalid descriptor class (String or Symbol required)') unless metric_descriptor.class == String || metric_descriptor.class == Symbol
32
+ raise(Split::InvalidExperimentsFormatError, 'Enable configuration') unless Split.configuration.enabled
33
+ raise(Split::InvalidExperimentsFormatError, 'Enable `allow_multiple_experiments`') unless Split.configuration.allow_multiple_experiments
34
+ experiment = Split::configuration.experiments[metric_descriptor.to_sym]
35
+ end
36
+ end
37
+ end
@@ -25,6 +25,7 @@ module Split
25
25
  attr_accessor :on_before_experiment_delete
26
26
  attr_accessor :include_rails_helper
27
27
  attr_accessor :beta_probability_simulations
28
+ attr_accessor :winning_alternative_recalculation_interval
28
29
  attr_accessor :redis
29
30
 
30
31
  attr_reader :experiments
@@ -48,7 +49,9 @@ module Split
48
49
  'spider' => 'generic web spider',
49
50
  'UnwindFetchor' => 'Gnip crawler',
50
51
  'WordPress' => 'WordPress spider',
52
+ 'YandexAccessibilityBot' => 'Yandex accessibility spider',
51
53
  'YandexBot' => 'Yandex spider',
54
+ 'YandexMobileBot' => 'Yandex mobile spider',
52
55
  'ZIBB' => 'ZIBB spider',
53
56
 
54
57
  # HTTP libraries
@@ -73,10 +76,13 @@ module Split
73
76
  'facebookexternalhit' => 'facebook bot',
74
77
  'Feedfetcher-Google' => 'Google Feedfetcher',
75
78
  'https://developers.google.com/+/web/snippet' => 'Google+ Snippet Fetcher',
79
+ 'LinkedInBot' => 'LinkedIn bot',
76
80
  'LongURL' => 'URL expander service',
77
81
  'NING' => 'NING - Yet Another Twitter Swarmer',
82
+ 'Pinterest' => 'Pinterest Bot',
78
83
  'redditbot' => 'Reddit Bot',
79
84
  'ShortLinkTranslate' => 'Link shortener',
85
+ 'Slackbot' => 'Slackbot link expander',
80
86
  'TweetmemeBot' => 'TweetMeMe Crawler',
81
87
  'Twitterbot' => 'Twitter URL expander',
82
88
  'UnwindFetch' => 'Gnip URL expander',
@@ -212,6 +218,7 @@ module Split
212
218
  @algorithm = Split::Algorithms::WeightedSample
213
219
  @include_rails_helper = true
214
220
  @beta_probability_simulations = 10000
221
+ @winning_alternative_recalculation_interval = 60 * 60 * 24 # 1 day
215
222
  @redis = ENV.fetch(ENV.fetch('REDIS_PROVIDER', 'REDIS_URL'), 'redis://localhost:6379')
216
223
  end
217
224
 
data/lib/split/engine.rb CHANGED
@@ -5,6 +5,8 @@ module Split
5
5
  if Split.configuration.include_rails_helper
6
6
  ActionController::Base.send :include, Split::Helper
7
7
  ActionController::Base.helper Split::Helper
8
+ ActionController::Base.send :include, Split::CombinedExperimentsHelper
9
+ ActionController::Base.helper Split::CombinedExperimentsHelper
8
10
  end
9
11
  end
10
12
  end
@@ -262,10 +262,11 @@ module Split
262
262
  end
263
263
 
264
264
  def calc_winning_alternatives
265
- # Super simple cache so that we only recalculate winning alternatives once per day
266
- days_since_epoch = Time.now.utc.to_i / 86400
265
+ # Cache the winning alternatives so we recalculate them once per the specified interval.
266
+ intervals_since_epoch =
267
+ Time.now.utc.to_i / Split.configuration.winning_alternative_recalculation_interval
267
268
 
268
- if self.calc_time != days_since_epoch
269
+ if self.calc_time != intervals_since_epoch
269
270
  if goals.empty?
270
271
  self.estimate_winning_alternative
271
272
  else
@@ -274,7 +275,7 @@ module Split
274
275
  end
275
276
  end
276
277
 
277
- self.calc_time = days_since_epoch
278
+ self.calc_time = intervals_since_epoch
278
279
 
279
280
  self.save
280
281
  end
data/lib/split/helper.rb CHANGED
@@ -10,6 +10,7 @@ module Split
10
10
  experiment = ExperimentCatalog.find_or_initialize(metric_descriptor, control, *alternatives)
11
11
  alternative = if Split.configuration.enabled
12
12
  experiment.save
13
+ raise(Split::InvalidExperimentsFormatError) unless (Split.configuration.experiments || {}).fetch(experiment.name.to_sym, {})[:combined_experiments].nil?
13
14
  trial = Trial.new(:user => ab_user, :experiment => experiment,
14
15
  :override => override_alternative(experiment.name), :exclude => exclude_visitor?,
15
16
  :disabled => split_generically_disabled?)
@@ -96,6 +97,14 @@ module Split
96
97
  Split.configuration.db_failover_on_db_error.call(e)
97
98
  end
98
99
 
100
+ def ab_active_experiments()
101
+ ab_user.active_experiments
102
+ rescue => e
103
+ raise unless Split.configuration.db_failover
104
+ Split.configuration.db_failover_on_db_error.call(e)
105
+ end
106
+
107
+
99
108
  def override_present?(experiment_name)
100
109
  override_alternative(experiment_name)
101
110
  end
@@ -6,20 +6,21 @@ module Split
6
6
  class CookieAdapter
7
7
 
8
8
  def initialize(context)
9
- @cookies = context.send(:cookies)
9
+ @request, @response = context.request, context.response
10
+ @cookies = @request.cookies
10
11
  @expires = Time.now + cookie_length_config
11
12
  end
12
13
 
13
14
  def [](key)
14
- hash[key]
15
+ hash[key.to_s]
15
16
  end
16
17
 
17
18
  def []=(key, value)
18
- set_cookie(hash.merge(key => value))
19
+ set_cookie(hash.merge!(key.to_s => value))
19
20
  end
20
21
 
21
22
  def delete(key)
22
- set_cookie(hash.tap { |h| h.delete(key) })
23
+ set_cookie(hash.tap { |h| h.delete(key.to_s) })
23
24
  end
24
25
 
25
26
  def keys
@@ -28,22 +29,25 @@ module Split
28
29
 
29
30
  private
30
31
 
31
- def set_cookie(value)
32
- @cookies[:split] = {
33
- :value => JSON.generate(value),
34
- :expires => @expires
35
- }
32
+ def set_cookie(value = {})
33
+ @response.set_cookie :split.to_s, default_options.merge(value: JSON.generate(value))
34
+ end
35
+
36
+ def default_options
37
+ { expires: @expires, path: '/' }
36
38
  end
37
39
 
38
40
  def hash
39
- if @cookies[:split]
40
- begin
41
- JSON.parse(@cookies[:split])
42
- rescue JSON::ParserError
41
+ @hash ||= begin
42
+ if cookies = @cookies[:split.to_s]
43
+ begin
44
+ JSON.parse(cookies)
45
+ rescue JSON::ParserError
46
+ {}
47
+ end
48
+ else
43
49
  {}
44
50
  end
45
- else
46
- {}
47
51
  end
48
52
  end
49
53
 
data/lib/split/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Split
3
3
  MAJOR = 3
4
- MINOR = 0
4
+ MINOR = 2
5
5
  PATCH = 0
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
data/lib/split.rb CHANGED
@@ -13,6 +13,7 @@ require 'split/experiment_catalog'
13
13
  require 'split/extensions/string'
14
14
  require 'split/goals_collection'
15
15
  require 'split/helper'
16
+ require 'split/combined_experiments_helper'
16
17
  require 'split/metric'
17
18
  require 'split/persistence'
18
19
  require 'split/redis_interface'
@@ -273,6 +273,18 @@ describe Split::Alternative do
273
273
  expect(control.z_score(goal1)).to eq('N/A')
274
274
  expect(control.z_score(goal2)).to eq('N/A')
275
275
  end
276
+
277
+ it "should not blow up for Conversion Rates > 1" do
278
+ control = experiment.control
279
+ control.participant_count = 3474
280
+ control.set_completed_count(4244)
281
+
282
+ alternative2.participant_count = 3434
283
+ alternative2.set_completed_count(4358)
284
+
285
+ expect { control.z_score }.not_to raise_error
286
+ expect { alternative2.z_score }.not_to raise_error
287
+ end
276
288
  end
277
289
 
278
290
  describe "extra_info" do
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'split/combined_experiments_helper'
4
+
5
+ describe Split::CombinedExperimentsHelper do
6
+ include Split::CombinedExperimentsHelper
7
+
8
+ describe 'ab_combined_test' do
9
+ let!(:config_enabled) { true }
10
+ let!(:combined_experiments) { [:exp_1_click, :exp_1_scroll ]}
11
+ let!(:allow_multiple_experiments) { true }
12
+
13
+ before do
14
+ Split.configuration.experiments = {
15
+ :combined_exp_1 => {
16
+ :alternatives => [ {"control"=> 0.5}, {"test-alt"=> 0.5} ],
17
+ :metric => :my_metric,
18
+ :combined_experiments => combined_experiments
19
+ }
20
+ }
21
+ Split.configuration.enabled = config_enabled
22
+ Split.configuration.allow_multiple_experiments = allow_multiple_experiments
23
+ end
24
+
25
+ context 'without config enabled' do
26
+ let!(:config_enabled) { false }
27
+
28
+ it "raises an error" do
29
+ expect(lambda { ab_combined_test :combined_exp_1 }).to raise_error(Split::InvalidExperimentsFormatError )
30
+ end
31
+ end
32
+
33
+ context 'multiple experiments disabled' do
34
+ let!(:allow_multiple_experiments) { false }
35
+
36
+ it "raises an error if multiple experiments is disabled" do
37
+ expect(lambda { ab_combined_test :combined_exp_1 }).to raise_error(Split::InvalidExperimentsFormatError)
38
+ end
39
+ end
40
+
41
+ context 'without combined experiments' do
42
+ let!(:combined_experiments) { nil }
43
+
44
+ it "raises an error" do
45
+ expect(lambda { ab_combined_test :combined_exp_1 }).to raise_error(Split::InvalidExperimentsFormatError )
46
+ end
47
+ end
48
+
49
+ it "uses same alternative for all sub experiments and returns the alternative" do
50
+ allow(self).to receive(:get_alternative) { "test-alt" }
51
+ expect(self).to receive(:ab_test).with(:exp_1_click, {"control"=>0.5}, {"test-alt"=>0.5}) { "test-alt" }
52
+ expect(self).to receive(:ab_test).with(:exp_1_scroll, [{"control" => 0, "test-alt" => 1}])
53
+
54
+ expect(ab_combined_test('combined_exp_1')).to eq('test-alt')
55
+ end
56
+ end
57
+ end
@@ -458,7 +458,7 @@ describe Split::Experiment do
458
458
  expect(experiment.alternatives[0].p_winner).to be_within(0.04).of(0.50)
459
459
  end
460
460
 
461
- it "should calculate the probability of being the winning alternative separately for each goal" do
461
+ it "should calculate the probability of being the winning alternative separately for each goal", :skip => true do
462
462
  experiment = Split::ExperimentCatalog.find_or_create({'link_color3' => ["purchase", "refund"]}, 'blue', 'red', 'green')
463
463
  goal1 = experiment.goals[0]
464
464
  goal2 = experiment.goals[1]
data/spec/helper_spec.rb CHANGED
@@ -35,6 +35,18 @@ describe Split::Helper do
35
35
  expect(lambda { ab_test({'link_color' => "purchase"}, 'blue', 'red') }).not_to raise_error
36
36
  end
37
37
 
38
+ it "raises an appropriate error when processing combined expirements" do
39
+ Split.configuration.experiments = {
40
+ :combined_exp_1 => {
41
+ :alternatives => [ { name: "control", percent: 50 }, { name: "test-alt", percent: 50 } ],
42
+ :metric => :my_metric,
43
+ :combined_experiments => [:combined_exp_1_sub_1]
44
+ }
45
+ }
46
+ Split::ExperimentCatalog.find_or_create('combined_exp_1')
47
+ expect(lambda { ab_test('combined_exp_1')}).to raise_error(Split::InvalidExperimentsFormatError )
48
+ end
49
+
38
50
  it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
39
51
  ab_test('link_color', 'blue', 'red')
40
52
  expect(['red', 'blue']).to include(ab_user['link_color'])
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
  require "spec_helper"
3
+ require 'rack/test'
3
4
 
4
5
  describe Split::Persistence::CookieAdapter do
5
6
 
6
- let(:context) { double(:cookies => CookiesMock.new) }
7
+ let(:env) { Rack::MockRequest.env_for("http://example.com:8080/") }
8
+ let(:request) { Rack::Request.new(env) }
9
+ let(:response) { Rack::MockResponse.new(200, {}, "") }
10
+ let(:context) { double(request: request, response: response) }
7
11
  subject { Split::Persistence::CookieAdapter.new(context) }
8
12
 
9
13
  describe "#[] and #[]=" do
@@ -30,7 +34,7 @@ describe Split::Persistence::CookieAdapter do
30
34
  end
31
35
 
32
36
  it "handles invalid JSON" do
33
- context.cookies[:split] = { :value => '{"foo":2,', :expires => Time.now }
37
+ context.request.cookies[:split] = { :value => '{"foo":2,', :expires => Time.now }
34
38
  expect(subject["my_key"]).to be_nil
35
39
  subject["my_key"] = "my_value"
36
40
  expect(subject["my_key"]).to eq("my_value")
@@ -47,7 +47,7 @@ describe Split::Persistence::DualAdapter do
47
47
  context "when logged in" do
48
48
  subject {
49
49
  described_class.with_config(
50
- logged_in: -> (context) { true },
50
+ logged_in: lambda { |context| true },
51
51
  logged_in_adapter: selected_adapter,
52
52
  logged_out_adapter: not_selected_adapter
53
53
  ).new(context)
@@ -59,7 +59,7 @@ describe Split::Persistence::DualAdapter do
59
59
  context "when not logged in" do
60
60
  subject {
61
61
  described_class.with_config(
62
- logged_in: -> (context) { false },
62
+ logged_in: lambda { |context| false },
63
63
  logged_in_adapter: not_selected_adapter,
64
64
  logged_out_adapter: selected_adapter
65
65
  ).new(context)
data/split.gemspec CHANGED
@@ -12,7 +12,17 @@ Gem::Specification.new do |s|
12
12
  s.homepage = "https://github.com/splitrb/split"
13
13
  s.summary = "Rack based split testing framework"
14
14
 
15
- s.required_ruby_version = '>= 1.9.2'
15
+ s.metadata = {
16
+ "homepage_uri" => "https://github.com/splitrb/split",
17
+ "changelog_uri" => "https://github.com/splitrb/split/blob/master/CHANGELOG.md",
18
+ "source_code_uri" => "https://github.com/splitrb/split",
19
+ "bug_tracker_uri" => "https://github.com/splitrb/split/issues",
20
+ "wiki_uri" => "https://github.com/splitrb/split/wiki",
21
+ "mailing_list_uri" => "https://groups.google.com/d/forum/split-ruby"
22
+ }
23
+
24
+ s.required_ruby_version = '>= 1.9.3'
25
+ s.required_rubygems_version = '>= 2.0.0'
16
26
 
17
27
  s.rubyforge_project = "split"
18
28
 
@@ -24,10 +34,10 @@ Gem::Specification.new do |s|
24
34
  s.add_dependency 'sinatra', '>= 1.2.6'
25
35
  s.add_dependency 'simple-random', '>= 0.9.3'
26
36
 
27
- s.add_development_dependency 'bundler', '~> 1.10'
37
+ s.add_development_dependency 'bundler', '~> 1.14'
28
38
  s.add_development_dependency 'simplecov', '~> 0.12'
29
39
  s.add_development_dependency 'rack-test', '~> 0.6'
30
- s.add_development_dependency 'rake', '~> 11.1'
40
+ s.add_development_dependency 'rake', '~> 12'
31
41
  s.add_development_dependency 'rspec', '~> 3.4'
32
42
  s.add_development_dependency 'pry', '~> 0.10'
33
43
  s.add_development_dependency 'fakeredis', '~> 0.6.0'
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.0.0
4
+ version: 3.2.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: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.10'
61
+ version: '1.14'
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.10'
68
+ version: '1.14'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '11.1'
103
+ version: '12'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '11.1'
110
+ version: '12'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -174,11 +174,13 @@ files:
174
174
  - Rakefile
175
175
  - gemfiles/4.2.gemfile
176
176
  - gemfiles/5.0.gemfile
177
+ - gemfiles/5.1.gemfile
177
178
  - lib/split.rb
178
179
  - lib/split/algorithms/block_randomization.rb
179
180
  - lib/split/algorithms/weighted_sample.rb
180
181
  - lib/split/algorithms/whiplash.rb
181
182
  - lib/split/alternative.rb
183
+ - lib/split/combined_experiments_helper.rb
182
184
  - lib/split/configuration.rb
183
185
  - lib/split/dashboard.rb
184
186
  - lib/split/dashboard/helpers.rb
@@ -215,6 +217,7 @@ files:
215
217
  - spec/algorithms/weighted_sample_spec.rb
216
218
  - spec/algorithms/whiplash_spec.rb
217
219
  - spec/alternative_spec.rb
220
+ - spec/combined_experiments_helper_spec.rb
218
221
  - spec/configuration_spec.rb
219
222
  - spec/dashboard_helpers_spec.rb
220
223
  - spec/dashboard_spec.rb
@@ -239,7 +242,13 @@ files:
239
242
  homepage: https://github.com/splitrb/split
240
243
  licenses:
241
244
  - MIT
242
- metadata: {}
245
+ metadata:
246
+ homepage_uri: https://github.com/splitrb/split
247
+ changelog_uri: https://github.com/splitrb/split/blob/master/CHANGELOG.md
248
+ source_code_uri: https://github.com/splitrb/split
249
+ bug_tracker_uri: https://github.com/splitrb/split/issues
250
+ wiki_uri: https://github.com/splitrb/split/wiki
251
+ mailing_list_uri: https://groups.google.com/d/forum/split-ruby
243
252
  post_install_message:
244
253
  rdoc_options: []
245
254
  require_paths:
@@ -248,12 +257,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
248
257
  requirements:
249
258
  - - ">="
250
259
  - !ruby/object:Gem::Version
251
- version: 1.9.2
260
+ version: 1.9.3
252
261
  required_rubygems_version: !ruby/object:Gem::Requirement
253
262
  requirements:
254
263
  - - ">="
255
264
  - !ruby/object:Gem::Version
256
- version: '0'
265
+ version: 2.0.0
257
266
  requirements: []
258
267
  rubyforge_project: split
259
268
  rubygems_version: 2.6.4
@@ -265,6 +274,7 @@ test_files:
265
274
  - spec/algorithms/weighted_sample_spec.rb
266
275
  - spec/algorithms/whiplash_spec.rb
267
276
  - spec/alternative_spec.rb
277
+ - spec/combined_experiments_helper_spec.rb
268
278
  - spec/configuration_spec.rb
269
279
  - spec/dashboard_helpers_spec.rb
270
280
  - spec/dashboard_spec.rb