Sha256: cb1c0d00a47e9521f3e38f1d4eb47fa4d37a438c9aba733a3c40ebaa4ab2d99a

Contents?: true

Size: 817 Bytes

Versions: 4

Compression:

Stored size: 817 Bytes

Contents

require "spec_helper"

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
split-0.7.2 spec/algorithms/weighted_sample_spec.rb
split-0.7.1 spec/algorithms/weighted_sample_spec.rb
split-0.7.0 spec/algorithms/weighted_sample_spec.rb
split-0.6.6 spec/algorithms/weighted_sample_spec.rb