Sha256: 2f98351e96ce89d98087c400fb39174d1c1eb37aa6c30a98ae9351ac3e0c8755
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
# frozen_string_literal: true require "spec_helper" require "split/combined_experiments_helper" describe Split::CombinedExperimentsHelper do include Split::CombinedExperimentsHelper describe "ab_combined_test" do let!(:config_enabled) { true } let!(:combined_experiments) { [:exp_1_click, :exp_1_scroll ] } let!(:allow_multiple_experiments) { true } before do Split.configuration.experiments = { combined_exp_1: { alternatives: [ { "control"=> 0.5 }, { "test-alt"=> 0.5 } ], metric: :my_metric, combined_experiments: combined_experiments } } Split.configuration.enabled = config_enabled Split.configuration.allow_multiple_experiments = allow_multiple_experiments end context "without config enabled" do let!(:config_enabled) { false } it "raises an error" do expect { ab_combined_test :combined_exp_1 }.to raise_error(Split::InvalidExperimentsFormatError) end end context "multiple experiments disabled" do let!(:allow_multiple_experiments) { false } it "raises an error if multiple experiments is disabled" do expect { ab_combined_test :combined_exp_1 }.to raise_error(Split::InvalidExperimentsFormatError) end end context "without combined experiments" do let!(:combined_experiments) { nil } it "raises an error" do expect { ab_combined_test :combined_exp_1 }.to raise_error(Split::InvalidExperimentsFormatError) end end it "uses same alternative for all sub experiments and returns the alternative" do allow(self).to receive(:get_alternative) { "test-alt" } expect(self).to receive(:ab_test).with(:exp_1_click, { "control"=>0.5 }, { "test-alt"=>0.5 }) { "test-alt" } expect(self).to receive(:ab_test).with(:exp_1_scroll, [{ "control" => 0, "test-alt" => 1 }]) expect(ab_combined_test("combined_exp_1")).to eq("test-alt") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
split-4.0.4 | spec/combined_experiments_helper_spec.rb |
split-4.0.3 | spec/combined_experiments_helper_spec.rb |
split-4.0.2 | spec/combined_experiments_helper_spec.rb |