Skip to content

Commit

Permalink
Merge upstream into configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Vasilyev committed Apr 15, 2015
2 parents b55f36b + 2f1c347 commit bd8cef1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 48 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ language: ruby
rvm:
- 1.9.3
- 2.2.2

services:
- redis-server
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Sixpack

[![Build Status](https://travis-ci.org/seatgeek/sixpack-rb.svg?branch=master)](https://travis-ci.org/seatgeek/sixpack-rb)

Ruby client library for SeatGeek's Sixpack ab testing framework.

## Installation
Expand Down
4 changes: 2 additions & 2 deletions lib/sixpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def initialize(client_id=nil, options={}, params={})

def participate(experiment_name, alternatives, force=nil)
if !(experiment_name =~ /^[a-z0-9][a-z0-9\-_ ]*$/)
raise ArgumentError, "Bad experiment_name"
raise ArgumentError, "Bad experiment_name, must be lowercase, start with an alphanumeric and contain alphanumerics, dashes and underscores"
end

if alternatives.length < 2
Expand All @@ -58,7 +58,7 @@ def participate(experiment_name, alternatives, force=nil)

alternatives.each { |alt|
if !(alt =~ /^[a-z0-9][a-z0-9\-_ ]*$/)
raise ArgumentError, "Bad alternative name: #{alt}"
raise ArgumentError, "Bad alternative name: #{alt}, must be lowercase, start with an alphanumeric and contain alphanumerics, dashes and underscores"
end
}

Expand Down
46 changes: 0 additions & 46 deletions spec/lib/sixpack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,6 @@
sess.client_id.length.should == 36
end

it "should return ok for convert" do
sess = Sixpack::Session.new("mike")
alternative = sess.participate('show-bieber', ['trolled', 'not-trolled'])
sess.convert("show-bieber")["status"].should == "ok"
end

it "should return ok for multiple_converts" do
sess = Sixpack::Session.new("mike")
sess.participate('show-bieber', ['trolled', 'not-trolled'])
sess.convert("show-bieber")["status"].should == "ok"
sess.convert("show-bieber")["status"].should == "ok"
end

it "should not return ok for convert with new id" do
sess = Sixpack::Session.new("unknown_id")
sess.convert("show-bieber")["status"].should == "failed"
end

it "should not return ok for convert with new experiment" do
sess = Sixpack::Session.new
sess.convert("show-blieber")['status'].should == "failed"
end

it "should not allow bad experiment names" do
expect {
sess = Sixpack::Session.new
Expand All @@ -105,27 +82,4 @@
}.to raise_error
end

it "should work" do
session = Sixpack::Session.new
session.convert("testing")["status"].should == "failed"
alt_one = session.participate("testing", ["one", "two"])["alternative"]
3.times do |n|
session.participate("testing", ["one", "two"])["alternative"].should == alt_one
end
session.convert("testing")["status"].should == "ok"

old_client_id = session.client_id
session.client_id = Sixpack::generate_client_id()
session.convert("testing")["status"].should == "failed"
alt_two = session.participate("testing", ["one", "two"])["alternative"]
3.times do |n|
session.participate("testing", ["one", "two"])["alternative"].should == alt_two
end
session.convert("testing")["status"].should == "ok"

session = Sixpack::Session.new old_client_id
3.times do |n|
session.participate("testing", ["one", "two"])["alternative"].should == alt_one
end
end
end

0 comments on commit bd8cef1

Please sign in to comment.