split 0.2.3 → 0.2.4

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.
@@ -1,3 +1,13 @@
1
+ ## 0.2.4 (July 18, 2011)
2
+
3
+ Features:
4
+
5
+ - Added option to finished to not reset the users session
6
+
7
+ Bugfixes:
8
+
9
+ - Only allow strings as alternatives, fixes strange errors when passing true/false or symbols
10
+
1
11
  ## 0.2.3 (June 26, 2011)
2
12
 
3
13
  Features:
@@ -95,6 +95,8 @@ Example: Conversion tracking (in a view)
95
95
 
96
96
  Thanks for signing up, dude! <% finished("signup_page_redesign") >
97
97
 
98
+ You can find more examples, tutorials and guides on the [wiki](https://github.com/andrew/split/wiki).
99
+
98
100
  ### Overriding alternatives
99
101
 
100
102
  For development and testing, you may wish to force your app to always return an alternative.
@@ -214,4 +216,4 @@ Tests can be ran with `rake spec`
214
216
 
215
217
  ## Copyright
216
218
 
217
- Copyright (c) 2011 Andrew Nesbitt. See LICENSE for details.
219
+ Copyright (c) 2011 Andrew Nesbitt. See [LICENSE](https://github.com/andrew/split/blob/master/LICENSE) for details.
@@ -106,7 +106,10 @@ module Split
106
106
  end
107
107
 
108
108
  def self.find_or_create(key, *alternatives)
109
- name = key.split(':')[0]
109
+ name = key.to_s.split(':')[0]
110
+
111
+ raise InvalidArgument, 'Alternatives must be strings' if alternatives.map(&:class).uniq != [String]
112
+
110
113
  if Split.redis.exists(name)
111
114
  if load_alternatives_for(name) == alternatives
112
115
  experiment = self.new(name, *load_alternatives_for(name))
@@ -34,13 +34,13 @@ module Split
34
34
  end
35
35
  end
36
36
 
37
- def finished(experiment_name)
37
+ def finished(experiment_name, options = {:reset => true})
38
38
  return if exclude_visitor?
39
39
  experiment = Split::Experiment.find(experiment_name)
40
40
  if alternative_name = ab_user[experiment.key]
41
41
  alternative = Split::Alternative.find(alternative_name, experiment_name)
42
42
  alternative.increment_completion
43
- session[:split].delete(experiment_name)
43
+ session[:split].delete(experiment_name) if options[:reset]
44
44
  end
45
45
  end
46
46
 
@@ -1,3 +1,3 @@
1
1
  module Split
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -9,6 +9,8 @@ describe Split::Dashboard do
9
9
  @app ||= Split::Dashboard
10
10
  end
11
11
 
12
+ before(:each) { Split.redis.flushall }
13
+
12
14
  it "should respond to /" do
13
15
  get '/'
14
16
  last_response.should be_ok
@@ -160,4 +160,11 @@ describe Split::Experiment do
160
160
  new_blue.participant_count.should eql(0)
161
161
  end
162
162
  end
163
+
164
+ describe 'alternatives passed as non-strings' do
165
+ it "should throw an exception if an alternative is passed that is not a string" do
166
+ lambda { Split::Experiment.find_or_create('link_color', :blue, :red) }.should raise_error
167
+ lambda { Split::Experiment.find_or_create('link_enabled', true, false) }.should raise_error
168
+ end
169
+ end
163
170
  end
@@ -83,6 +83,17 @@ describe Split::Helper do
83
83
  finished('link_color')
84
84
  session[:split].should == {}
85
85
  end
86
+
87
+ it "should not clear out the users session if reset is false" do
88
+ experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red')
89
+ alternative_name = ab_test('link_color', 'blue', 'red')
90
+
91
+ previous_completion_count = Split::Alternative.find(alternative_name, 'link_color').completed_count
92
+
93
+ session[:split].should eql("link_color" => alternative_name)
94
+ finished('link_color', :reset => false)
95
+ session[:split].should eql("link_color" => alternative_name)
96
+ end
86
97
  end
87
98
 
88
99
  describe 'conversions' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Nesbitt
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-26 00:00:00 +01:00
18
+ date: 2011-07-18 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency