Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ rvm:
- 2.6.6
- 2.7.1

services:
- redis-server

gemfile:
- gemfiles/5.0.gemfile
- gemfiles/5.1.gemfile
Expand Down
2 changes: 1 addition & 1 deletion lib/split/experiment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def validate!
end

def new_record?
!redis.exists(name)
!redis.exists?(name)
end

def ==(obj)
Expand Down
2 changes: 1 addition & 1 deletion lib/split/experiment_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.all_active_first
end

def self.find(name)
return unless Split.redis.exists(name)
return unless Split.redis.exists?(name)
Experiment.new(name).tap { |exp| exp.load_from_redis }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/alternative_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

it "should save to redis" do
alternative.save
expect(Split.redis.exists('basket_text:Basket')).to be true
expect(Split.redis.exists?('basket_text:Basket')).to be true
end

it "should increment participation count" do
Expand Down
1 change: 1 addition & 0 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
it "should use the ENV variable" do
ENV['REDIS_URL'] = "env_redis_url"
expect(Split::Configuration.new.redis).to eq("env_redis_url")
ENV.delete('REDIS_URL')
end
end
end
Expand Down
18 changes: 3 additions & 15 deletions spec/experiment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def alternative(color)

it "should save to redis" do
experiment.save
expect(Split.redis.exists('basket_text')).to be true
expect(Split.redis.exists?('basket_text')).to be true
end

it "should save the start time to redis" do
Expand Down Expand Up @@ -85,7 +85,7 @@ def alternative(color)
it "should not create duplicates when saving multiple times" do
experiment.save
experiment.save
expect(Split.redis.exists('basket_text')).to be true
expect(Split.redis.exists?('basket_text')).to be true
expect(Split.redis.lrange('basket_text', 0, -1)).to eq(['{"Basket":1}', '{"Cart":1}'])
end

Expand Down Expand Up @@ -197,7 +197,7 @@ def alternative(color)
experiment.save

experiment.delete
expect(Split.redis.exists('link_color')).to be false
expect(Split.redis.exists?('link_color')).to be false
expect(Split::ExperimentCatalog.find('link_color')).to be_nil
end

Expand Down Expand Up @@ -414,18 +414,6 @@ def alternative(color)
end
end

describe "#disable_cohorting" do
it "saves a new key in redis" do
expect(experiment.disable_cohorting).to eq true
end
end

describe "#enable_cohorting" do
it "saves a new key in redis" do
expect(experiment.enable_cohorting).to eq true
end
end

describe 'changing an existing experiment' do
def same_but_different_alternative
Split::ExperimentCatalog.find_or_create('link_color', 'blue', 'yellow', 'orange')
Expand Down
2 changes: 1 addition & 1 deletion spec/goals_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
goals_collection.save

goals_collection.delete
expect(Split.redis.exists(goals_key)).to be false
expect(Split.redis.exists?(goals_key)).to be false
end
end

Expand Down
10 changes: 4 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@

Dir['./spec/support/*.rb'].each { |f| require f }

require "fakeredis"

G_fakeredis = Redis.new

module GlobalSharedContext
extend RSpec::SharedContext
let(:mock_user){ Split::User.new(double(session: {})) }

before(:each) do
Split.configuration = Split::Configuration.new
Split.redis = G_fakeredis
Split.redis.flushall
Split.redis = Redis.new
Split.redis.select(10)
Split.redis.flushdb
@ab_user = mock_user
params = nil
end
Expand Down
3 changes: 1 addition & 2 deletions split.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ["lib"]

s.add_dependency 'redis', '>= 2.1'
s.add_dependency 'redis', '>= 4.2'
s.add_dependency 'sinatra', '>= 1.2.6'
s.add_dependency 'rubystats', '>= 0.3.0'

Expand All @@ -39,6 +39,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 13'
s.add_development_dependency 'rspec', '~> 3.7'
s.add_development_dependency 'pry', '~> 0.10'
s.add_development_dependency 'fakeredis', '~> 0.7'
s.add_development_dependency 'rails', '>= 5.0'
end