|
89 | 89 | expect(ab_test('link_color', 'blue', 'red')).to eq('orange') |
90 | 90 | end |
91 | 91 |
|
92 | | - it "should allow the alternative to be force by passing it in the params" do |
93 | | - @params = {'link_color' => 'blue'} |
| 92 | + it "should allow the alternative to be forced by passing it in the params" do |
| 93 | + # ?ab_test[link_color]=blue |
| 94 | + @params = { 'ab_test' => { 'link_color' => 'blue' } } |
| 95 | + |
94 | 96 | alternative = ab_test('link_color', 'blue', 'red') |
95 | 97 | expect(alternative).to eq('blue') |
| 98 | + |
96 | 99 | alternative = ab_test('link_color', {'blue' => 1}, 'red' => 5) |
97 | 100 | expect(alternative).to eq('blue') |
98 | | - @params = {'link_color' => 'red'} |
| 101 | + |
| 102 | + @params = { 'ab_test' => { 'link_color' => 'red' } } |
| 103 | + |
99 | 104 | alternative = ab_test('link_color', 'blue', 'red') |
100 | 105 | expect(alternative).to eq('red') |
| 106 | + |
101 | 107 | alternative = ab_test('link_color', {'blue' => 5}, 'red' => 1) |
102 | 108 | expect(alternative).to eq('red') |
103 | 109 | end |
104 | 110 |
|
105 | 111 | it "should not allow an arbitrary alternative" do |
106 | | - @params = {'link_color' => 'pink'} |
| 112 | + @params = { 'ab_test' => { 'link_color' => 'pink' } } |
107 | 113 | alternative = ab_test('link_color', 'blue') |
108 | 114 | expect(alternative).to eq('blue') |
109 | 115 | end |
110 | 116 |
|
111 | 117 | it "should not store the split when a param forced alternative" do |
112 | | - @params = {'link_color' => 'blue'} |
| 118 | + @params = { 'ab_test' => { 'link_color' => 'blue' } } |
113 | 119 | expect(ab_user).not_to receive(:[]=) |
114 | 120 | ab_test('link_color', 'blue', 'red') |
115 | 121 | end |
|
136 | 142 | before { Split.configuration.store_override = true } |
137 | 143 |
|
138 | 144 | it "should store the forced alternative" do |
139 | | - @params = {'link_color' => 'blue'} |
| 145 | + @params = { 'ab_test' => { 'link_color' => 'blue' } } |
140 | 146 | expect(ab_user).to receive(:[]=).with('link_color', 'blue') |
141 | 147 | ab_test('link_color', 'blue', 'red') |
142 | 148 | end |
|
232 | 238 | end |
233 | 239 |
|
234 | 240 | it 'should be passed to helper block' do |
235 | | - @params = {'my_experiment' => 'one'} |
| 241 | + @params = { 'ab_test' => { 'my_experiment' => 'one' } } |
236 | 242 | expect(ab_test('my_experiment')).to eq 'one' |
237 | 243 | expect(ab_test('my_experiment') do |alternative, meta| |
238 | 244 | meta |
@@ -790,7 +796,7 @@ def should_finish_experiment(experiment_name, should_finish=true) |
790 | 796 |
|
791 | 797 | context 'and given an override parameter' do |
792 | 798 | it 'should use given override instead of the first alternative' do |
793 | | - @params = {'link_color' => 'red'} |
| 799 | + @params = { 'ab_test' => { 'link_color' => 'red' } } |
794 | 800 | expect(ab_test('link_color', 'blue', 'red')).to eq('red') |
795 | 801 | expect(ab_test('link_color', 'blue', 'red', 'green')).to eq('red') |
796 | 802 | expect(ab_test('link_color', {'blue' => 0.01}, 'red' => 0.2)).to eq('red') |
|
0 commit comments