Sha256: 3a2a32942619a4ca61ca4a36b9ca4c4e412e816c35849eecb9bad97550ca764f

Contents?: true

Size: 883 Bytes

Versions: 27

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true
require "spec_helper"

describe Split::Algorithms::WeightedSample do
  it "should return an alternative" do
    experiment = Split::ExperimentCatalog.find_or_create('link_color', {'blue' => 100}, {'red' => 0 })
    expect(Split::Algorithms::WeightedSample.choose_alternative(experiment).class).to eq(Split::Alternative)
  end

  it "should always return a heavily weighted option" do
    experiment = Split::ExperimentCatalog.find_or_create('link_color', {'blue' => 100}, {'red' => 0 })
    expect(Split::Algorithms::WeightedSample.choose_alternative(experiment).name).to eq('blue')
  end

  it "should return one of the results" do
    experiment = Split::ExperimentCatalog.find_or_create('link_color', {'blue' => 1}, {'red' => 1 })
    expect(['red', 'blue']).to include Split::Algorithms::WeightedSample.choose_alternative(experiment).name
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
split-4.0.1 spec/algorithms/weighted_sample_spec.rb
split-4.0.0.pre2 spec/algorithms/weighted_sample_spec.rb
split-4.0.0.pre spec/algorithms/weighted_sample_spec.rb
ab-split-1.0.2 spec/algorithms/weighted_sample_spec.rb
ab-split-1.0.1 spec/algorithms/weighted_sample_spec.rb
ab-split-1.0.0 spec/algorithms/weighted_sample_spec.rb
split-3.4.1 spec/algorithms/weighted_sample_spec.rb
split-3.4.0 spec/algorithms/weighted_sample_spec.rb
split-3.3.2 spec/algorithms/weighted_sample_spec.rb
split-3.3.1 spec/algorithms/weighted_sample_spec.rb
split-3.3.0 spec/algorithms/weighted_sample_spec.rb
split-3.2.0 spec/algorithms/weighted_sample_spec.rb
split-3.1.1 spec/algorithms/weighted_sample_spec.rb
split-3.1.0 spec/algorithms/weighted_sample_spec.rb
split-3.0.0 spec/algorithms/weighted_sample_spec.rb
split-2.2.0 spec/algorithms/weighted_sample_spec.rb
split-2.1.0 spec/algorithms/weighted_sample_spec.rb
split-2.0.0 spec/algorithms/weighted_sample_spec.rb
split-1.7.0 spec/algorithms/weighted_sample_spec.rb
split-1.6.0 spec/algorithms/weighted_sample_spec.rb