Skip to content

Commit e6d07d2

Browse files
committed
Endpoint should accept multiple alternatives
* Given the [definition][definition] of the `ab_test` helper, it should accept and pass multiple alternatives [definition]: https://github.com/splitrb/split/blob/52ecd67bbe5c28ab85bd2abb48509f14cdbd1f21/lib/split/helper.rb#L5
1 parent 9bdf0d9 commit e6d07d2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/split/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class API < Sinatra::Base
1111
experiment = params[:experiment]
1212
control = params[:control]
1313
alternatives = params[:alternatives]
14-
alternative = ab_test(experiment, control, alternatives)
14+
alternative = ab_test(experiment, control, *alternatives)
1515
MultiJson.encode({:alternative => alternative})
1616
end
1717

spec/api_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@ def app
88
end
99

1010
before(:each) { Split.redis.flushall }
11-
11+
1212
describe '/ab_test' do
1313
it "should respond" do
1414
get '/ab_test', :experiment => 'text_color', :control => 'red', :alternatives => 'blue'
1515
last_response.should be_ok
1616
end
17-
17+
18+
it 'should accept an array of alternatives' do
19+
get '/ab_test', :experiment => 'text_color', :control => 'red', :alternatives => ['blue', 'green', 'yellow']
20+
last_response.should be_ok
21+
end
22+
1823
it 'should set the correct session variable'
1924
end
20-
25+
2126
describe '/finished' do
2227
it "should respond" do
2328
post '/finished', :experiment => 'text_color'
2429
last_response.should be_ok
2530
end
26-
31+
2732
it 'should handle having an empty session'
2833
end
29-
end
34+
end

0 commit comments

Comments
 (0)