split 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ describe Split::Metric do
5
5
  describe 'possible experiments' do
6
6
  it "should load the experiment if there is one, but no metric" do
7
7
  experiment = Split::Experiment.find_or_create('color', 'red', 'blue')
8
- Split::Metric.possible_experiments('color').should == [experiment]
8
+ expect(Split::Metric.possible_experiments('color')).to eq([experiment])
9
9
  end
10
10
 
11
11
  it "should load the experiments in a metric" do
@@ -14,7 +14,7 @@ describe Split::Metric do
14
14
 
15
15
  metric = Split::Metric.new(:name => 'purchase', :experiments => [experiment1, experiment2])
16
16
  metric.save
17
- Split::Metric.possible_experiments('purchase').should include(experiment1, experiment2)
17
+ expect(Split::Metric.possible_experiments('purchase')).to include(experiment1, experiment2)
18
18
  end
19
19
 
20
20
  it "should load both the metric experiments and an experiment with the same name" do
@@ -23,7 +23,7 @@ describe Split::Metric do
23
23
 
24
24
  metric = Split::Metric.new(:name => 'purchase', :experiments => [experiment2])
25
25
  metric.save
26
- Split::Metric.possible_experiments('purchase').should include(experiment1, experiment2)
26
+ expect(Split::Metric.possible_experiments('purchase')).to include(experiment1, experiment2)
27
27
  end
28
28
  end
29
29
 
@@ -8,7 +8,7 @@ describe Split::Persistence::CookieAdapter do
8
8
  describe "#[] and #[]=" do
9
9
  it "should set and return the value for given key" do
10
10
  subject["my_key"] = "my_value"
11
- subject["my_key"].should eq("my_value")
11
+ expect(subject["my_key"]).to eq("my_value")
12
12
  end
13
13
  end
14
14
 
@@ -16,7 +16,7 @@ describe Split::Persistence::CookieAdapter do
16
16
  it "should delete the given key" do
17
17
  subject["my_key"] = "my_value"
18
18
  subject.delete("my_key")
19
- subject["my_key"].should be_nil
19
+ expect(subject["my_key"]).to be_nil
20
20
  end
21
21
  end
22
22
 
@@ -24,15 +24,15 @@ describe Split::Persistence::CookieAdapter do
24
24
  it "should return an array of the session's stored keys" do
25
25
  subject["my_key"] = "my_value"
26
26
  subject["my_second_key"] = "my_second_value"
27
- subject.keys.should =~ ["my_key", "my_second_key"]
27
+ expect(subject.keys).to match(["my_key", "my_second_key"])
28
28
  end
29
29
  end
30
30
 
31
31
  it "handles invalid JSON" do
32
32
  context.cookies[:split] = { :value => '{"foo":2,', :expires => Time.now }
33
- subject["my_key"].should be_nil
33
+ expect(subject["my_key"]).to be_nil
34
34
  subject["my_key"] = "my_value"
35
- subject["my_key"].should eq("my_value")
35
+ expect(subject["my_key"]).to eq("my_value")
36
36
  end
37
37
 
38
38
  end
@@ -20,7 +20,7 @@ describe Split::Persistence::RedisAdapter do
20
20
  before { Split::Persistence::RedisAdapter.with_config(:lookup_by => proc{'block'}) }
21
21
 
22
22
  it 'should be "persistence:block"' do
23
- subject.redis_key.should == 'persistence:block'
23
+ expect(subject.redis_key).to eq('persistence:block')
24
24
  end
25
25
  end
26
26
 
@@ -29,7 +29,7 @@ describe Split::Persistence::RedisAdapter do
29
29
  let(:context) { double(:test => 'block') }
30
30
 
31
31
  it 'should be "persistence:block"' do
32
- subject.redis_key.should == 'persistence:block'
32
+ expect(subject.redis_key).to eq('persistence:block')
33
33
  end
34
34
  end
35
35
 
@@ -38,7 +38,7 @@ describe Split::Persistence::RedisAdapter do
38
38
  let(:context) { double(:method_name => 'val') }
39
39
 
40
40
  it 'should be "persistence:bar"' do
41
- subject.redis_key.should == 'persistence:val'
41
+ expect(subject.redis_key).to eq('persistence:val')
42
42
  end
43
43
  end
44
44
 
@@ -46,7 +46,7 @@ describe Split::Persistence::RedisAdapter do
46
46
  before { Split::Persistence::RedisAdapter.with_config(:lookup_by => proc{'frag'}, :namespace => 'namer') }
47
47
 
48
48
  it 'should be "namer"' do
49
- subject.redis_key.should == 'namer:frag'
49
+ expect(subject.redis_key).to eq('namer:frag')
50
50
  end
51
51
  end
52
52
  end
@@ -57,7 +57,7 @@ describe Split::Persistence::RedisAdapter do
57
57
  describe "#[] and #[]=" do
58
58
  it "should set and return the value for given key" do
59
59
  subject["my_key"] = "my_value"
60
- subject["my_key"].should eq("my_value")
60
+ expect(subject["my_key"]).to eq("my_value")
61
61
  end
62
62
  end
63
63
 
@@ -65,7 +65,7 @@ describe Split::Persistence::RedisAdapter do
65
65
  it "should delete the given key" do
66
66
  subject["my_key"] = "my_value"
67
67
  subject.delete("my_key")
68
- subject["my_key"].should be_nil
68
+ expect(subject["my_key"]).to be_nil
69
69
  end
70
70
  end
71
71
 
@@ -73,7 +73,7 @@ describe Split::Persistence::RedisAdapter do
73
73
  it "should return an array of the user's stored keys" do
74
74
  subject["my_key"] = "my_value"
75
75
  subject["my_second_key"] = "my_second_value"
76
- subject.keys.should =~ ["my_key", "my_second_key"]
76
+ expect(subject.keys).to match(["my_key", "my_second_key"])
77
77
  end
78
78
  end
79
79
 
@@ -8,7 +8,7 @@ describe Split::Persistence::SessionAdapter do
8
8
  describe "#[] and #[]=" do
9
9
  it "should set and return the value for given key" do
10
10
  subject["my_key"] = "my_value"
11
- subject["my_key"].should eq("my_value")
11
+ expect(subject["my_key"]).to eq("my_value")
12
12
  end
13
13
  end
14
14
 
@@ -16,7 +16,7 @@ describe Split::Persistence::SessionAdapter do
16
16
  it "should delete the given key" do
17
17
  subject["my_key"] = "my_value"
18
18
  subject.delete("my_key")
19
- subject["my_key"].should be_nil
19
+ expect(subject["my_key"]).to be_nil
20
20
  end
21
21
  end
22
22
 
@@ -24,8 +24,8 @@ describe Split::Persistence::SessionAdapter do
24
24
  it "should return an array of the session's stored keys" do
25
25
  subject["my_key"] = "my_value"
26
26
  subject["my_second_key"] = "my_second_value"
27
- subject.keys.should =~ ["my_key", "my_second_key"]
27
+ expect(subject.keys).to match(["my_key", "my_second_key"])
28
28
  end
29
29
  end
30
30
 
31
- end
31
+ end
@@ -7,27 +7,27 @@ describe Split::Persistence do
7
7
  describe ".adapter" do
8
8
  context "when the persistence config is a symbol" do
9
9
  it "should return the appropriate adapter for the symbol" do
10
- Split.configuration.stub(:persistence).and_return(:cookie)
11
- subject.adapter.should eq(Split::Persistence::CookieAdapter)
10
+ expect(Split.configuration).to receive(:persistence).twice.and_return(:cookie)
11
+ expect(subject.adapter).to eq(Split::Persistence::CookieAdapter)
12
12
  end
13
13
 
14
14
  it "should return an adapter whose class is present in Split::Persistence::ADAPTERS" do
15
- Split.configuration.stub(:persistence).and_return(:cookie)
16
- Split::Persistence::ADAPTERS.values.should include(subject.adapter)
15
+ expect(Split.configuration).to receive(:persistence).twice.and_return(:cookie)
16
+ expect(Split::Persistence::ADAPTERS.values).to include(subject.adapter)
17
17
  end
18
18
 
19
19
  it "should raise if the adapter cannot be found" do
20
- Split.configuration.stub(:persistence).and_return(:something_weird)
20
+ expect(Split.configuration).to receive(:persistence).twice.and_return(:something_weird)
21
21
  expect { subject.adapter }.to raise_error
22
22
  end
23
23
  end
24
24
  context "when the persistence config is a class" do
25
25
  let(:custom_adapter_class) { MyCustomAdapterClass = Class.new }
26
26
  it "should return that class" do
27
- Split.configuration.stub(:persistence).and_return(custom_adapter_class)
28
- subject.adapter.should eq(MyCustomAdapterClass)
27
+ expect(Split.configuration).to receive(:persistence).twice.and_return(custom_adapter_class)
28
+ expect(subject.adapter).to eq(MyCustomAdapterClass)
29
29
  end
30
30
  end
31
31
  end
32
32
 
33
- end
33
+ end
@@ -6,17 +6,17 @@ describe Split::Trial do
6
6
  experiment = double('experiment')
7
7
  alternative = double('alternative', :kind_of? => Split::Alternative)
8
8
  trial = Split::Trial.new(:experiment => experiment, :alternative => alternative)
9
- trial.experiment.should == experiment
10
- trial.alternative.should == alternative
11
- trial.goals.should == []
9
+ expect(trial.experiment).to eq(experiment)
10
+ expect(trial.alternative).to eq(alternative)
11
+ expect(trial.goals).to eq([])
12
12
  end
13
13
 
14
14
  describe "alternative" do
15
15
  it "should use the alternative if specified" do
16
16
  alternative = double('alternative', :kind_of? => Split::Alternative)
17
17
  trial = Split::Trial.new(:experiment => experiment = double('experiment'), :alternative => alternative)
18
- trial.should_not_receive(:choose)
19
- trial.alternative.should == alternative
18
+ expect(trial).not_to receive(:choose)
19
+ expect(trial.alternative).to eq(alternative)
20
20
  end
21
21
 
22
22
  it "should populate alternative with a full alternative object after calling choose" do
@@ -24,8 +24,8 @@ describe Split::Trial do
24
24
  experiment.save
25
25
  trial = Split::Trial.new(:experiment => experiment)
26
26
  trial.choose
27
- trial.alternative.class.should == Split::Alternative
28
- ['basket', 'cart'].should include(trial.alternative.name)
27
+ expect(trial.alternative.class).to eq(Split::Alternative)
28
+ expect(['basket', 'cart']).to include(trial.alternative.name)
29
29
  end
30
30
 
31
31
  it "should populate an alternative when only one option is offerred" do
@@ -33,20 +33,20 @@ describe Split::Trial do
33
33
  experiment.save
34
34
  trial = Split::Trial.new(:experiment => experiment)
35
35
  trial.choose
36
- trial.alternative.class.should == Split::Alternative
37
- trial.alternative.name.should == 'basket'
36
+ expect(trial.alternative.class).to eq(Split::Alternative)
37
+ expect(trial.alternative.name).to eq('basket')
38
38
  end
39
39
 
40
40
 
41
41
  it "should choose from the available alternatives" do
42
42
  trial = Split::Trial.new(:experiment => experiment = double('experiment'))
43
43
  alternative = double('alternative', :kind_of? => Split::Alternative)
44
- experiment.should_receive(:next_alternative).and_return(alternative)
45
- alternative.should_receive(:increment_participation)
46
- experiment.stub(:winner).and_return nil
44
+ expect(experiment).to receive(:next_alternative).and_return(alternative)
45
+ expect(alternative).to receive(:increment_participation)
46
+ expect(experiment).to receive(:winner).at_most(1).times.and_return(nil)
47
47
  trial.choose!
48
48
 
49
- trial.alternative.should == alternative
49
+ expect(trial.alternative).to eq(alternative)
50
50
  end
51
51
  end
52
52
 
@@ -56,7 +56,7 @@ describe Split::Trial do
56
56
  experiment.save
57
57
 
58
58
  trial = Split::Trial.new(:experiment => experiment, :alternative => 'basket')
59
- trial.alternative.name.should == 'basket'
59
+ expect(trial.alternative.name).to eq('basket')
60
60
  end
61
61
  end
62
62
  end
@@ -29,8 +29,8 @@ Gem::Specification.new do |s|
29
29
  end
30
30
 
31
31
  s.add_development_dependency 'rake'
32
- s.add_development_dependency 'bundler', '~> 1.3'
33
- s.add_development_dependency 'rspec', '~> 2.14'
34
- s.add_development_dependency 'rack-test', '>= 0.5.7'
32
+ s.add_development_dependency 'bundler', '~> 1.6'
33
+ s.add_development_dependency 'rspec', '~> 3.0'
34
+ s.add_development_dependency 'rack-test'
35
35
  s.add_development_dependency 'coveralls'
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-12 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -86,42 +86,42 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.3'
89
+ version: '1.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.3'
96
+ version: '1.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.14'
103
+ version: '3.0'
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: '2.14'
110
+ version: '3.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rack-test
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 0.5.7
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 0.5.7
124
+ version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: coveralls
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -157,9 +157,7 @@ files:
157
157
  - gemfiles/3.1.gemfile
158
158
  - gemfiles/3.1.gemfile.lock
159
159
  - gemfiles/3.2.gemfile
160
- - gemfiles/3.2.gemfile.lock
161
160
  - gemfiles/4.0.gemfile
162
- - gemfiles/4.0.gemfile.lock
163
161
  - lib/split.rb
164
162
  - lib/split/algorithms.rb
165
163
  - lib/split/algorithms/weighted_sample.rb
@@ -1,123 +0,0 @@
1
- PATH
2
- remote: /Users/andrew/code/split
3
- specs:
4
- split (0.6.1)
5
- redis (>= 2.1)
6
- redis-namespace (>= 1.1.0)
7
- simple-random
8
- sinatra (>= 1.2.6)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- actionmailer (3.2.13)
14
- actionpack (= 3.2.13)
15
- mail (~> 2.5.3)
16
- actionpack (3.2.13)
17
- activemodel (= 3.2.13)
18
- activesupport (= 3.2.13)
19
- builder (~> 3.0.0)
20
- erubis (~> 2.7.0)
21
- journey (~> 1.0.4)
22
- rack (~> 1.4.5)
23
- rack-cache (~> 1.2)
24
- rack-test (~> 0.6.1)
25
- sprockets (~> 2.2.1)
26
- activemodel (3.2.13)
27
- activesupport (= 3.2.13)
28
- builder (~> 3.0.0)
29
- activerecord (3.2.13)
30
- activemodel (= 3.2.13)
31
- activesupport (= 3.2.13)
32
- arel (~> 3.0.2)
33
- tzinfo (~> 0.3.29)
34
- activeresource (3.2.13)
35
- activemodel (= 3.2.13)
36
- activesupport (= 3.2.13)
37
- activesupport (3.2.13)
38
- i18n (= 0.6.1)
39
- multi_json (~> 1.0)
40
- appraisal (0.5.2)
41
- bundler
42
- rake
43
- arel (3.0.2)
44
- builder (3.0.4)
45
- diff-lcs (1.2.4)
46
- erubis (2.7.0)
47
- hike (1.2.2)
48
- i18n (0.6.1)
49
- journey (1.0.4)
50
- json (1.7.7)
51
- mail (2.5.3)
52
- i18n (>= 0.4.0)
53
- mime-types (~> 1.16)
54
- treetop (~> 1.4.8)
55
- mime-types (1.23)
56
- multi_json (1.7.2)
57
- polyglot (0.3.3)
58
- rack (1.4.5)
59
- rack-cache (1.2)
60
- rack (>= 0.4)
61
- rack-protection (1.5.0)
62
- rack
63
- rack-ssl (1.3.3)
64
- rack
65
- rack-test (0.6.2)
66
- rack (>= 1.0)
67
- rails (3.2.13)
68
- actionmailer (= 3.2.13)
69
- actionpack (= 3.2.13)
70
- activerecord (= 3.2.13)
71
- activeresource (= 3.2.13)
72
- activesupport (= 3.2.13)
73
- bundler (~> 1.0)
74
- railties (= 3.2.13)
75
- railties (3.2.13)
76
- actionpack (= 3.2.13)
77
- activesupport (= 3.2.13)
78
- rack-ssl (~> 1.3.2)
79
- rake (>= 0.8.7)
80
- rdoc (~> 3.4)
81
- thor (>= 0.14.6, < 2.0)
82
- rake (10.0.4)
83
- rdoc (3.12.2)
84
- json (~> 1.4)
85
- redis (3.0.4)
86
- redis-namespace (1.3.0)
87
- redis (~> 3.0.0)
88
- rspec (2.13.0)
89
- rspec-core (~> 2.13.0)
90
- rspec-expectations (~> 2.13.0)
91
- rspec-mocks (~> 2.13.0)
92
- rspec-core (2.13.1)
93
- rspec-expectations (2.13.0)
94
- diff-lcs (>= 1.1.3, < 2.0)
95
- rspec-mocks (2.13.1)
96
- simple-random (0.9.3)
97
- sinatra (1.3.4)
98
- rack (~> 1.4)
99
- rack-protection (~> 1.3)
100
- tilt (~> 1.3, >= 1.3.3)
101
- sprockets (2.2.2)
102
- hike (~> 1.2)
103
- multi_json (~> 1.0)
104
- rack (~> 1.0)
105
- tilt (~> 1.1, != 1.3.0)
106
- thor (0.18.1)
107
- tilt (1.4.0)
108
- treetop (1.4.12)
109
- polyglot
110
- polyglot (>= 0.3.1)
111
- tzinfo (0.3.37)
112
-
113
- PLATFORMS
114
- ruby
115
-
116
- DEPENDENCIES
117
- appraisal
118
- bundler (~> 1.3)
119
- rack-test (>= 0.5.7)
120
- rails (~> 3.2.13)
121
- rake
122
- rspec (~> 2.12)
123
- split!