Sha256: 68e8e03a988ba4052331470a1ec3e99bef6904312be0a30585a6517c0a5499d9

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

require "spec_helper"

describe Split::Algorithms::BlockRandomization do

  let(:experiment) { Split::Experiment.new 'experiment' }
  let(:alternative_A) { Split::Alternative.new 'A', 'experiment' }
  let(:alternative_B) { Split::Alternative.new 'B', 'experiment' }
  let(:alternative_C) { Split::Alternative.new 'C', 'experiment' }

  before :each do
    allow(experiment).to receive(:alternatives) { [alternative_A, alternative_B, alternative_C] }
  end

  it "should return an alternative" do
    expect(Split::Algorithms::BlockRandomization.choose_alternative(experiment).class).to eq(Split::Alternative)
  end

  it "should always return the minimum participation option" do
    allow(alternative_A).to receive(:participant_count) { 1 }
    allow(alternative_B).to receive(:participant_count) { 1 }
    allow(alternative_C).to receive(:participant_count) { 0 }
    expect(Split::Algorithms::BlockRandomization.choose_alternative(experiment)).to eq(alternative_C)
  end

  it "should return one of the minimum participation options when multiple" do
    allow(alternative_A).to receive(:participant_count) { 0 }
    allow(alternative_B).to receive(:participant_count) { 0 }
    allow(alternative_C).to receive(:participant_count) { 0 }
    alternative = Split::Algorithms::BlockRandomization.choose_alternative(experiment)
    expect([alternative_A, alternative_B, alternative_C].include?(alternative)).to be(true)
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
split-4.0.1 spec/algorithms/block_randomization_spec.rb
split-4.0.0.pre2 spec/algorithms/block_randomization_spec.rb
split-4.0.0.pre spec/algorithms/block_randomization_spec.rb
ab-split-1.0.2 spec/algorithms/block_randomization_spec.rb
ab-split-1.0.1 spec/algorithms/block_randomization_spec.rb
ab-split-1.0.0 spec/algorithms/block_randomization_spec.rb
split-3.4.1 spec/algorithms/block_randomization_spec.rb
split-3.4.0 spec/algorithms/block_randomization_spec.rb
split-3.3.2 spec/algorithms/block_randomization_spec.rb
split-3.3.1 spec/algorithms/block_randomization_spec.rb
split-3.3.0 spec/algorithms/block_randomization_spec.rb
split-3.2.0 spec/algorithms/block_randomization_spec.rb
split-3.1.1 spec/algorithms/block_randomization_spec.rb
split-3.1.0 spec/algorithms/block_randomization_spec.rb
split-3.0.0 spec/algorithms/block_randomization_spec.rb