split 3.0.0 → 3.1.1

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: c5fbcc8e3abf30d53af50aa09b77ceab245d58a1
4
+ data.tar.gz: 0b576e850d6d066a06aaf599b0970622f22c1041
5
5
  SHA512:
6
- metadata.gz: 41138ef7911a9843cbc3fa81f78b28184087dacfff4d291d820ae32faf343fce0a9552f4d0123d647751ceadf8c1f242d44bd7e476e50a69165a49b13e422e27
7
- data.tar.gz: c8cfabeb28e143872e7c81f5d3e4dd28f2cb9c8d274f21a31481eaa52725eed06876ef6959ad44aacb84c47f064c84953d2edffd4767951774011037aff28e96
6
+ metadata.gz: 9a05fd38b874ffa595a76445673c3916c9d00835b641b17416fc41e48eadb731c13377e886889dbecc90aa88c1f2a6264ae11cdb33d9a41043ffde999355b8b1
7
+ data.tar.gz: 6491c8f886f1b90e90df207103c2fd52c545ae3f9219f1e43f10c67f2d4b15d57542eb7cb27ace064e58f9163f20938dbeb89d7a115b91ed205e28716f7e04dc
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.1
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,33 @@
1
+ ## 3.1.1 (August 30th, 2017)
2
+
3
+ Bugfixes:
4
+
5
+ - Bring back support for ruby 1.9.3 and greater (rubygems 2.0.0 or greater now required) (@patbl, #498)
6
+
7
+ Misc:
8
+
9
+ - Document testing with RSpec (@eliotsykes, #495)
10
+
11
+ ## 3.1.0 (August 14th, 2017)
12
+
13
+ Features:
14
+
15
+ - Support for combined experiments (@daviddening, #493)
16
+ - Rewrite CookieAdapter to work with Rack::Request and Rack::Response directly (@andrehjr, #490)
17
+ - Enumeration of a User's Experiments that Respects the db_failover Option(@MarkRoddy, #487)
18
+
19
+ Bugfixes:
20
+
21
+ - Blocked a few more common bot user agents (@kylerippey, #485)
22
+
23
+ Misc:
24
+
25
+ - Repository Audit by Maintainer.io (@RichardLitt, #484)
26
+ - Update development dependencies
27
+ - Test on ruby 2.4.1
28
+ - Test compatibility with rails 5.1
29
+ - Add uris to metadata section in gemspec
30
+
1
31
  ## 3.0.0 (March 30th, 2017)
2
32
 
3
33
  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
11
+ Split is a rack based A/B testing framework designed to work with Rails, Sinatra or any other rack based app.
16
12
 
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
52
-
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,7 +115,6 @@ 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
 
187
-
188
118
  ## Extras
189
119
 
190
120
  ### Weighted alternatives
@@ -220,9 +150,39 @@ In the event you want to disable all tests without having to know the individual
220
150
 
221
151
  It is not required to send `SPLIT_DISABLE=false` to activate Split.
222
152
 
153
+ To aid testing with RSpec, write `split_helper.rb` and call `use_ab_test(alternatives_by_experiment)` in your specs as instructed below:
154
+
155
+ ```ruby
156
+ # Recommended path for this file is 'spec/support/split_helper.rb', and you will need to ensure it
157
+ # is `require`-d by rails_helper.rb or spec_helper.rb
158
+ module SplitHelper
159
+
160
+ # Usage:
161
+ #
162
+ # Force a specific experiment alternative to always be returned:
163
+ # use_ab_test(signup_form: "single_page")
164
+ #
165
+ # Force alternatives for multiple experiments:
166
+ # use_ab_test(signup_form: "single_page", pricing: "show_enterprise_prices")
167
+ #
168
+ def use_ab_test(alternatives_by_experiment)
169
+ allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment|
170
+ alternative =
171
+ alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" }
172
+ end
173
+ end
174
+ end
175
+
176
+ RSpec.configure do |config|
177
+ # Make the `use_ab_test` method available to all specs:
178
+ config.include SplitHelper
179
+ end
180
+ ```
181
+
182
+
223
183
  ### Starting experiments manually
224
184
 
225
- By default new AB tests will be active right after deployment. In case you would like to start new test a while after
185
+ 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
186
  the deploy, you can do it by setting the `start_manually` configuration option to `true`.
227
187
 
228
188
  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 +435,7 @@ You can override the default configuration options of Split like so:
475
435
 
476
436
  ```ruby
477
437
  Split.configure do |config|
478
- config.db_failover = true # handle redis errors gracefully
438
+ config.db_failover = true # handle Redis errors gracefully
479
439
  config.db_failover_on_db_error = -> (error) { Rails.logger.error(error.message) }
480
440
  config.allow_multiple_experiments = true
481
441
  config.enabled = true
@@ -693,6 +653,35 @@ Once you finish one of the goals, the test is considered to be completed, and fi
693
653
 
694
654
  **Bad Example**: Test both how button color affects signup *and* how it affects login, at the same time. THIS WILL NOT WORK.
695
655
 
656
+ #### Combined Experiments
657
+ If you want to test how how button color affects signup *and* how it affects login, at the same time. Use combined tests
658
+ Configure like so
659
+ ```ruby
660
+ Split.configuration.experiments = {
661
+ :button_color_experiment => {
662
+ :alternatives => ["blue", "green"],
663
+ :combined_experiments => ["button_color_on_signup", "button_color_on_login"]
664
+ }
665
+ }
666
+ ```
667
+
668
+ Starting the combined test starts all combined experiments
669
+ ```ruby
670
+ ab_combined_test(:button_color_experiment)
671
+ ```
672
+ Finish each combined test as normal
673
+
674
+ ```ruby
675
+ ab_finished(:button_color_on_login)
676
+ ab_finished(:button_color_on_signup)
677
+ ```
678
+
679
+ **Additional Configuration**:
680
+ * Be sure to enable `allow_multiple_experiments`
681
+ * In Sinatra include the CombinedExperimentsHelper
682
+ ```
683
+ helpers Split::CombinedExperimentsHelper
684
+ ```
696
685
  ### DB failover solution
697
686
 
698
687
  Due to the fact that Redis has no automatic failover mechanism, it's
@@ -811,12 +800,12 @@ end
811
800
 
812
801
  ## Extensions
813
802
 
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
803
+ - [Split::Export](http://github.com/splitrb/split-export) - Easily export A/B test data out of Split.
804
+ - [Split::Analytics](http://github.com/splitrb/split-analytics) - Push test data to Google Analytics.
805
+ - [Split::Mongoid](https://github.com/MongoHQ/split-mongoid) - Store experiment data in mongoid (still uses redis).
806
+ - [Split::Cacheable](https://github.com/harrystech/split_cacheable) - Automatically create cache buckets per test.
807
+ - [Split::Counters](https://github.com/bernardkroes/split-counters) - Add counters per experiment and alternative.
808
+ - [Split::Cli](https://github.com/craigmcnamara/split-cli) - A CLI to trigger Split A/B tests.
820
809
 
821
810
  ## Screencast
822
811
 
@@ -824,15 +813,93 @@ Ryan bates has produced an excellent 10 minute screencast about split on the Rai
824
813
 
825
814
  ## Blogposts
826
815
 
827
- * [A/B Testing with Split in Ruby on Rails](http://grinnick.com/posts/a-b-testing-with-split-in-ruby-on-rails)
828
816
  * [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
817
  * [Rails A/B testing with Split on Heroku](http://blog.nathanhumbert.com/2012/02/rails-ab-testing-with-split-on-heroku.html)
830
818
 
831
- ## Contributors
819
+ ## Backers
820
+
821
+ Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/split#backer)]
822
+
823
+ <a href="https://opencollective.com/split/backer/0/website" target="_blank"><img src="https://opencollective.com/split/backer/0/avatar.svg"></a>
824
+ <a href="https://opencollective.com/split/backer/1/website" target="_blank"><img src="https://opencollective.com/split/backer/1/avatar.svg"></a>
825
+ <a href="https://opencollective.com/split/backer/2/website" target="_blank"><img src="https://opencollective.com/split/backer/2/avatar.svg"></a>
826
+ <a href="https://opencollective.com/split/backer/3/website" target="_blank"><img src="https://opencollective.com/split/backer/3/avatar.svg"></a>
827
+ <a href="https://opencollective.com/split/backer/4/website" target="_blank"><img src="https://opencollective.com/split/backer/4/avatar.svg"></a>
828
+ <a href="https://opencollective.com/split/backer/5/website" target="_blank"><img src="https://opencollective.com/split/backer/5/avatar.svg"></a>
829
+ <a href="https://opencollective.com/split/backer/6/website" target="_blank"><img src="https://opencollective.com/split/backer/6/avatar.svg"></a>
830
+ <a href="https://opencollective.com/split/backer/7/website" target="_blank"><img src="https://opencollective.com/split/backer/7/avatar.svg"></a>
831
+ <a href="https://opencollective.com/split/backer/8/website" target="_blank"><img src="https://opencollective.com/split/backer/8/avatar.svg"></a>
832
+ <a href="https://opencollective.com/split/backer/9/website" target="_blank"><img src="https://opencollective.com/split/backer/9/avatar.svg"></a>
833
+ <a href="https://opencollective.com/split/backer/10/website" target="_blank"><img src="https://opencollective.com/split/backer/10/avatar.svg"></a>
834
+ <a href="https://opencollective.com/split/backer/11/website" target="_blank"><img src="https://opencollective.com/split/backer/11/avatar.svg"></a>
835
+ <a href="https://opencollective.com/split/backer/12/website" target="_blank"><img src="https://opencollective.com/split/backer/12/avatar.svg"></a>
836
+ <a href="https://opencollective.com/split/backer/13/website" target="_blank"><img src="https://opencollective.com/split/backer/13/avatar.svg"></a>
837
+ <a href="https://opencollective.com/split/backer/14/website" target="_blank"><img src="https://opencollective.com/split/backer/14/avatar.svg"></a>
838
+ <a href="https://opencollective.com/split/backer/15/website" target="_blank"><img src="https://opencollective.com/split/backer/15/avatar.svg"></a>
839
+ <a href="https://opencollective.com/split/backer/16/website" target="_blank"><img src="https://opencollective.com/split/backer/16/avatar.svg"></a>
840
+ <a href="https://opencollective.com/split/backer/17/website" target="_blank"><img src="https://opencollective.com/split/backer/17/avatar.svg"></a>
841
+ <a href="https://opencollective.com/split/backer/18/website" target="_blank"><img src="https://opencollective.com/split/backer/18/avatar.svg"></a>
842
+ <a href="https://opencollective.com/split/backer/19/website" target="_blank"><img src="https://opencollective.com/split/backer/19/avatar.svg"></a>
843
+ <a href="https://opencollective.com/split/backer/20/website" target="_blank"><img src="https://opencollective.com/split/backer/20/avatar.svg"></a>
844
+ <a href="https://opencollective.com/split/backer/21/website" target="_blank"><img src="https://opencollective.com/split/backer/21/avatar.svg"></a>
845
+ <a href="https://opencollective.com/split/backer/22/website" target="_blank"><img src="https://opencollective.com/split/backer/22/avatar.svg"></a>
846
+ <a href="https://opencollective.com/split/backer/23/website" target="_blank"><img src="https://opencollective.com/split/backer/23/avatar.svg"></a>
847
+ <a href="https://opencollective.com/split/backer/24/website" target="_blank"><img src="https://opencollective.com/split/backer/24/avatar.svg"></a>
848
+ <a href="https://opencollective.com/split/backer/25/website" target="_blank"><img src="https://opencollective.com/split/backer/25/avatar.svg"></a>
849
+ <a href="https://opencollective.com/split/backer/26/website" target="_blank"><img src="https://opencollective.com/split/backer/26/avatar.svg"></a>
850
+ <a href="https://opencollective.com/split/backer/27/website" target="_blank"><img src="https://opencollective.com/split/backer/27/avatar.svg"></a>
851
+ <a href="https://opencollective.com/split/backer/28/website" target="_blank"><img src="https://opencollective.com/split/backer/28/avatar.svg"></a>
852
+ <a href="https://opencollective.com/split/backer/29/website" target="_blank"><img src="https://opencollective.com/split/backer/29/avatar.svg"></a>
853
+
854
+
855
+ ## Sponsors
856
+
857
+ 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)]
858
+
859
+ <a href="https://opencollective.com/split/sponsor/0/website" target="_blank"><img src="https://opencollective.com/split/sponsor/0/avatar.svg"></a>
860
+ <a href="https://opencollective.com/split/sponsor/1/website" target="_blank"><img src="https://opencollective.com/split/sponsor/1/avatar.svg"></a>
861
+ <a href="https://opencollective.com/split/sponsor/2/website" target="_blank"><img src="https://opencollective.com/split/sponsor/2/avatar.svg"></a>
862
+ <a href="https://opencollective.com/split/sponsor/3/website" target="_blank"><img src="https://opencollective.com/split/sponsor/3/avatar.svg"></a>
863
+ <a href="https://opencollective.com/split/sponsor/4/website" target="_blank"><img src="https://opencollective.com/split/sponsor/4/avatar.svg"></a>
864
+ <a href="https://opencollective.com/split/sponsor/5/website" target="_blank"><img src="https://opencollective.com/split/sponsor/5/avatar.svg"></a>
865
+ <a href="https://opencollective.com/split/sponsor/6/website" target="_blank"><img src="https://opencollective.com/split/sponsor/6/avatar.svg"></a>
866
+ <a href="https://opencollective.com/split/sponsor/7/website" target="_blank"><img src="https://opencollective.com/split/sponsor/7/avatar.svg"></a>
867
+ <a href="https://opencollective.com/split/sponsor/8/website" target="_blank"><img src="https://opencollective.com/split/sponsor/8/avatar.svg"></a>
868
+ <a href="https://opencollective.com/split/sponsor/9/website" target="_blank"><img src="https://opencollective.com/split/sponsor/9/avatar.svg"></a>
869
+ <a href="https://opencollective.com/split/sponsor/10/website" target="_blank"><img src="https://opencollective.com/split/sponsor/10/avatar.svg"></a>
870
+ <a href="https://opencollective.com/split/sponsor/11/website" target="_blank"><img src="https://opencollective.com/split/sponsor/11/avatar.svg"></a>
871
+ <a href="https://opencollective.com/split/sponsor/12/website" target="_blank"><img src="https://opencollective.com/split/sponsor/12/avatar.svg"></a>
872
+ <a href="https://opencollective.com/split/sponsor/13/website" target="_blank"><img src="https://opencollective.com/split/sponsor/13/avatar.svg"></a>
873
+ <a href="https://opencollective.com/split/sponsor/14/website" target="_blank"><img src="https://opencollective.com/split/sponsor/14/avatar.svg"></a>
874
+ <a href="https://opencollective.com/split/sponsor/15/website" target="_blank"><img src="https://opencollective.com/split/sponsor/15/avatar.svg"></a>
875
+ <a href="https://opencollective.com/split/sponsor/16/website" target="_blank"><img src="https://opencollective.com/split/sponsor/16/avatar.svg"></a>
876
+ <a href="https://opencollective.com/split/sponsor/17/website" target="_blank"><img src="https://opencollective.com/split/sponsor/17/avatar.svg"></a>
877
+ <a href="https://opencollective.com/split/sponsor/18/website" target="_blank"><img src="https://opencollective.com/split/sponsor/18/avatar.svg"></a>
878
+ <a href="https://opencollective.com/split/sponsor/19/website" target="_blank"><img src="https://opencollective.com/split/sponsor/19/avatar.svg"></a>
879
+ <a href="https://opencollective.com/split/sponsor/20/website" target="_blank"><img src="https://opencollective.com/split/sponsor/20/avatar.svg"></a>
880
+ <a href="https://opencollective.com/split/sponsor/21/website" target="_blank"><img src="https://opencollective.com/split/sponsor/21/avatar.svg"></a>
881
+ <a href="https://opencollective.com/split/sponsor/22/website" target="_blank"><img src="https://opencollective.com/split/sponsor/22/avatar.svg"></a>
882
+ <a href="https://opencollective.com/split/sponsor/23/website" target="_blank"><img src="https://opencollective.com/split/sponsor/23/avatar.svg"></a>
883
+ <a href="https://opencollective.com/split/sponsor/24/website" target="_blank"><img src="https://opencollective.com/split/sponsor/24/avatar.svg"></a>
884
+ <a href="https://opencollective.com/split/sponsor/25/website" target="_blank"><img src="https://opencollective.com/split/sponsor/25/avatar.svg"></a>
885
+ <a href="https://opencollective.com/split/sponsor/26/website" target="_blank"><img src="https://opencollective.com/split/sponsor/26/avatar.svg"></a>
886
+ <a href="https://opencollective.com/split/sponsor/27/website" target="_blank"><img src="https://opencollective.com/split/sponsor/27/avatar.svg"></a>
887
+ <a href="https://opencollective.com/split/sponsor/28/website" target="_blank"><img src="https://opencollective.com/split/sponsor/28/avatar.svg"></a>
888
+ <a href="https://opencollective.com/split/sponsor/29/website" target="_blank"><img src="https://opencollective.com/split/sponsor/29/avatar.svg"></a>
832
889
 
833
- Over 70 different people have contributed to the project, you can see them all here: https://github.com/splitrb/split/graphs/contributors
890
+ ## Contribute
834
891
 
835
- ## Development
892
+ Please do! Over 70 different people have contributed to the project, you can see them all here: https://github.com/splitrb/split/graphs/contributors.
893
+
894
+ ### Development
895
+
896
+ The source code is hosted at [GitHub](http://github.com/splitrb/split).
897
+
898
+ Report issues and feature requests on [GitHub Issues](http://github.com/splitrb/split/issues).
899
+
900
+ You can find a discussion form on [Google Groups](https://groups.google.com/d/forum/split-ruby).
901
+
902
+ ### Tests
836
903
 
837
904
  Run the tests like this:
838
905
 
@@ -842,23 +909,21 @@ Run the tests like this:
842
909
  bundle
843
910
  rake spec
844
911
 
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
912
+ ### A Note on Patches and Pull Requests
852
913
 
853
914
  * Fork the project.
854
915
  * Make your feature addition or bug fix.
855
916
  * Add tests for it. This is important so I don't break it in a
856
917
  future version unintentionally.
857
918
  * 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)
919
+ * Commit. Do not mess with the rakefile, version, or history.
920
+ (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
921
  * Send a pull request. Bonus points for topic branches.
861
922
 
923
+ ### Code of Conduct
924
+
925
+ 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.
926
+
862
927
  ## Copyright
863
928
 
864
- Copyright (c) 2016 Andrew Nesbitt. See [LICENSE](https://github.com/splitrb/split/blob/master/LICENSE) for details.
929
+ [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: "../"
@@ -0,0 +1,30 @@
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
+ experiment[:combined_experiments].each do |combined_experiment|
10
+ if alternative.nil?
11
+ if control
12
+ alternative = ab_test(combined_experiment, control, alternatives)
13
+ else
14
+ normalized_alternatives = Split::Configuration.new.normalize_alternatives(experiment[:alternatives])
15
+ alternative = ab_test(combined_experiment, normalized_alternatives[0], *normalized_alternatives[1])
16
+ end
17
+ else
18
+ ab_test(combined_experiment, [{alternative => 1}])
19
+ end
20
+ end
21
+ end
22
+
23
+ def find_combined_experiment(metric_descriptor)
24
+ raise(Split::InvalidExperimentsFormatError, 'Invalid descriptor class (String or Symbol required)') unless metric_descriptor.class == String || metric_descriptor.class == Symbol
25
+ raise(Split::InvalidExperimentsFormatError, 'Enable configuration') unless Split.configuration.enabled
26
+ raise(Split::InvalidExperimentsFormatError, 'Enable `allow_multiple_experiments`') unless Split.configuration.allow_multiple_experiments
27
+ experiment = Split::configuration.experiments[metric_descriptor.to_sym]
28
+ end
29
+ end
30
+ end
@@ -48,7 +48,9 @@ module Split
48
48
  'spider' => 'generic web spider',
49
49
  'UnwindFetchor' => 'Gnip crawler',
50
50
  'WordPress' => 'WordPress spider',
51
+ 'YandexAccessibilityBot' => 'Yandex accessibility spider',
51
52
  'YandexBot' => 'Yandex spider',
53
+ 'YandexMobileBot' => 'Yandex mobile spider',
52
54
  'ZIBB' => 'ZIBB spider',
53
55
 
54
56
  # HTTP libraries
@@ -73,10 +75,13 @@ module Split
73
75
  'facebookexternalhit' => 'facebook bot',
74
76
  'Feedfetcher-Google' => 'Google Feedfetcher',
75
77
  'https://developers.google.com/+/web/snippet' => 'Google+ Snippet Fetcher',
78
+ 'LinkedInBot' => 'LinkedIn bot',
76
79
  'LongURL' => 'URL expander service',
77
80
  'NING' => 'NING - Yet Another Twitter Swarmer',
81
+ 'Pinterest' => 'Pinterest Bot',
78
82
  'redditbot' => 'Reddit Bot',
79
83
  'ShortLinkTranslate' => 'Link shortener',
84
+ 'Slackbot' => 'Slackbot link expander',
80
85
  'TweetmemeBot' => 'TweetMeMe Crawler',
81
86
  'Twitterbot' => 'Twitter URL expander',
82
87
  'UnwindFetch' => 'Gnip URL expander',
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
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
5
- PATCH = 0
4
+ MINOR = 1
5
+ PATCH = 1
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'
@@ -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 alternatives for all sub experiments " 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, [{"test-alt" => 1}] )
53
+
54
+ ab_combined_test('combined_exp_1')
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.1.1
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-08-30 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,15 +257,15 @@ 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
- rubygems_version: 2.6.4
268
+ rubygems_version: 2.6.11
260
269
  signing_key:
261
270
  specification_version: 4
262
271
  summary: Rack based split testing framework
@@ -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