Sha256: 4674afe48e763d94171cff93759ca0153dbf298b430e503f5c3ccef0b3a0d013
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'spec_helper' require 'split/experiment_catalog' require 'split/experiment' require 'split/user' describe Split::User do let(:context) do double(:session => { split: { 'link_color' => 'blue' } }) end before(:each) do @subject = described_class.new(context) end it 'delegates methods correctly' do expect(@subject['link_color']).to eq(@subject.user['link_color']) end context '#cleanup_old_experiments' do let(:experiment) { Split::Experiment.new('link_color') } it 'removes key if experiment is not found' do @subject.cleanup_old_experiments expect(@subject.keys).to be_empty end it 'removes key if experiment has a winner' do allow(Split::ExperimentCatalog).to receive(:find).with('link_color').and_return(experiment) allow(experiment).to receive(:start_time).and_return(Date.today) allow(experiment).to receive(:has_winner?).and_return(true) @subject.cleanup_old_experiments expect(@subject.keys).to be_empty end it 'removes key if experiment has not started yet' do allow(Split::ExperimentCatalog).to receive(:find).with('link_color').and_return(experiment) allow(experiment).to receive(:has_winner?).and_return(false) @subject.cleanup_old_experiments expect(@subject.keys).to be_empty end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
split-1.4.3 | spec/user_spec.rb |
split-1.4.2 | spec/user_spec.rb |